diff options
Diffstat (limited to '')
-rw-r--r-- | src/args.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/args.rs b/src/args.rs index b54c3cb..ee9cb7e 100644 --- a/src/args.rs +++ b/src/args.rs @@ -1,3 +1,4 @@ +use std::fmt::Display; use std::net::IpAddr; use std::path::PathBuf; @@ -15,6 +16,21 @@ pub enum MediaType { Video, } +#[derive(ValueEnum, Clone)] +pub enum SizeDisplay { + Human, + Exact, +} + +impl Display for SizeDisplay { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + SizeDisplay::Human => write!(f, "human"), + SizeDisplay::Exact => write!(f, "exact"), + } + } +} + #[derive(Parser)] #[command(name = "miniserve", author, about, version)] pub struct CliArgs { @@ -352,8 +368,8 @@ pub struct CliArgs { pub enable_webdav: bool, /// Show served file size in exact bytes. - #[arg(long, default_value = "false", env = "MINISERVE_SHOW_EXACT_BYTES")] - pub show_exact_bytes: bool, + #[arg(long, default_value_t = SizeDisplay::Human, env = "MINISERVE_SIZE_DISPLAY")] + pub size_display: SizeDisplay, } /// Checks whether an interface is valid, i.e. it can be parsed into an IP address |