diff --git a/src/cli.rs b/src/cli.rs index 5ef33b5..dcbf5d2 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -6,35 +6,32 @@ use clap::{Parser, builder::PossibleValuesParser}; #[command(version, about, long_about = None)] pub struct Cli { /// Timeout in seconds for HTTP actions - #[arg(short, long)] + #[arg(short, long, value_name = "SECS")] pub timeout: Option, /// Protocol for Sharry instance #[arg( short, long, - default_value_t = String::from("https"), - value_parser = PossibleValuesParser::new(["http", "https"]), + default_value = "https", value_name = "VARIANT", + value_parser = PossibleValuesParser::new(["http", "https"]) )] - pub proto: String, + pub protocol: String, /// Name of the new share - #[arg( - short, long, - default_value_t = String::from("shrupl upload"), - )] + #[arg(short, long, default_value = "shrupl upload", value_name = "TEXT")] pub name: String, /// Description of the new share - #[arg(short, long)] - pub desc: Option, + #[arg(short, long, value_name = "TEXT")] + pub description: Option, /// Maximum number of views for the new share - #[arg(short, long, default_value_t = 10)] - pub views: u32, + #[arg(short, long, default_value_t = 10, value_name = "N")] + pub max_views: u32, /// Chunk size for uploading, in MiB - #[arg(short, long, default_value_t = 10)] - pub chunk: usize, + #[arg(short, long, default_value_t = 10, value_name = "N")] + pub chunk_size: usize, /// Base URL for Sharry Instance pub url: String, diff --git a/src/main.rs b/src/main.rs index a54cfbd..e94ed2f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,9 +31,9 @@ fn main() { panic!("NO FILES GIVEN"); } - let alias = Alias::new(Uri::with_protocol(args.proto, args.url), args.alias); + let alias = Alias::new(Uri::with_protocol(args.protocol, args.url), args.alias); - let share = NewShareRequest::new(args.name, args.desc, args.views); + let share = NewShareRequest::new(args.name, args.description, args.max_views); let share = Share::create(&agent, &alias, share).unwrap(); info!("share: {share:?}"); @@ -41,7 +41,7 @@ fn main() { let file = file.create(&agent, &share).unwrap(); info!("file: {file:?}"); - for chunk in file.chunked(args.chunk * 1024 * 1024) { + for chunk in file.chunked(args.chunk_size * 1024 * 1024) { info!("chunk len: {}", chunk.bytes.len()); file.upload_chunk(&agent, &alias, &chunk)