Update README, use port and recursive from args, add bind to args
This commit is contained in:
parent
55b6cc1a10
commit
e19b0a7de9
17
README.md
17
README.md
|
@ -1,6 +1,23 @@
|
||||||
# Roulette
|
# Roulette
|
||||||
Serve a random image!
|
Serve a random image!
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
```
|
||||||
|
Serve a random image!
|
||||||
|
|
||||||
|
Usage: roulette-rs [OPTIONS] [PATHS]...
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
[PATHS]... Paths to search for images in
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-b, --bind <BIND> IP to bind to when serving on [default: 0.0.0.0]
|
||||||
|
-p, --port <PORT> Port to serve the http server on [default: 8080]
|
||||||
|
-r, --recursive Whether or not to recursively search for images in supplied paths
|
||||||
|
-h, --help Print help information
|
||||||
|
-V, --version Print version information
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
This project is a rust rewrite of a [friend's project](https://git.seedno.de/seednode/roulette) that I did for fun.
|
This project is a rust rewrite of a [friend's project](https://git.seedno.de/seednode/roulette) that I did for fun.
|
16
src/main.rs
16
src/main.rs
|
@ -6,19 +6,23 @@ use std::path::{PathBuf, Path};
|
||||||
use std::{io, fs};
|
use std::{io, fs};
|
||||||
use rand::seq::SliceRandom;
|
use rand::seq::SliceRandom;
|
||||||
|
|
||||||
/// Struct representing CLI arguments
|
/// Serve a random image!
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(author, version, about)]
|
#[command(author, version, about)]
|
||||||
struct CliArgs {
|
struct CliArgs {
|
||||||
/// Paths to search for images in.
|
/// Paths to search for images in
|
||||||
paths: Vec<PathBuf>,
|
paths: Vec<PathBuf>,
|
||||||
|
|
||||||
/// Port to serve the http server on.
|
/// IP to bind to when serving on
|
||||||
|
#[arg(short, long, default_value_t = String::from("0.0.0.0"))]
|
||||||
|
bind: String,
|
||||||
|
|
||||||
|
/// Port to serve the http server on
|
||||||
#[arg(short, long, default_value_t = 8080)]
|
#[arg(short, long, default_value_t = 8080)]
|
||||||
port: u16,
|
port: u16,
|
||||||
|
|
||||||
/// Wether or not to recursively search for images in supplied paths
|
/// Whether or not to recursively search for images in supplied paths
|
||||||
#[arg(short, long, default_value_t = true)]
|
#[arg(short, long, default_value_t = false)]
|
||||||
recursive: bool
|
recursive: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +188,7 @@ async fn main() -> std::io::Result<()> {
|
||||||
.app_data(web::Data::new(AppState::new(images.clone())))
|
.app_data(web::Data::new(AppState::new(images.clone())))
|
||||||
.service(serve_picture)
|
.service(serve_picture)
|
||||||
.service(chose_picture)
|
.service(chose_picture)
|
||||||
}).bind(("127.0.0.1", 8080))?
|
}).bind((args.bind, args.port))?
|
||||||
.run()
|
.run()
|
||||||
.await
|
.await
|
||||||
}
|
}
|
Loading…
Reference in New Issue