From d2e6c0d08ad1219cf2a04ebce512830bc2a26d54 Mon Sep 17 00:00:00 2001 From: Lzzzt Date: Thu, 6 Mar 2025 16:31:20 +1100 Subject: change cli args Signed-off-by: Lzzzt --- src/args.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/args.rs') 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 -- cgit v1.2.3