Update README, use port and recursive from args, add bind to args

This commit is contained in:
SeanOMik 2022-11-13 20:05:19 -05:00
parent 55b6cc1a10
commit e19b0a7de9
Signed by: SeanOMik
GPG Key ID: 568F326C7EB33ACB
2 changed files with 27 additions and 6 deletions

View File

@ -1,6 +1,23 @@
# Roulette
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.

View File

@ -6,19 +6,23 @@ use std::path::{PathBuf, Path};
use std::{io, fs};
use rand::seq::SliceRandom;
/// Struct representing CLI arguments
/// Serve a random image!
#[derive(Parser, Debug)]
#[command(author, version, about)]
struct CliArgs {
/// Paths to search for images in.
/// Paths to search for images in
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)]
port: u16,
/// Wether or not to recursively search for images in supplied paths
#[arg(short, long, default_value_t = true)]
/// Whether or not to recursively search for images in supplied paths
#[arg(short, long, default_value_t = false)]
recursive: bool
}
@ -184,7 +188,7 @@ async fn main() -> std::io::Result<()> {
.app_data(web::Data::new(AppState::new(images.clone())))
.service(serve_picture)
.service(chose_picture)
}).bind(("127.0.0.1", 8080))?
}).bind((args.bind, args.port))?
.run()
.await
}