diff options
author | Sven-Hendrik Haase <svenstaro@gmail.com> | 2025-03-06 23:17:51 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-06 23:17:51 +0000 |
commit | 1472a05b1c0c6b59af974235d8462f757cf1b0d8 (patch) | |
tree | 2aa07ddcba76d083583c75ff0be86147425630e3 /src/args.rs | |
parent | Add CHANGELOG entry for #1431 (diff) | |
parent | change cli args (diff) | |
download | miniserve-1472a05b1c0c6b59af974235d8462f757cf1b0d8.tar.gz miniserve-1472a05b1c0c6b59af974235d8462f757cf1b0d8.zip |
Merge pull request #1261 from Lzzzzzt/show-size-in-byte
Feature: Show size in byte
Diffstat (limited to 'src/args.rs')
-rw-r--r-- | src/args.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/args.rs b/src/args.rs index 72ade7b..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 { @@ -350,6 +366,10 @@ pub struct CliArgs { /// Currently incompatible with -P|--no-symlinks (see https://github.com/messense/dav-server-rs/issues/37) #[arg(long, env = "MINISERVE_ENABLE_WEBDAV", conflicts_with = "no_symlinks")] pub enable_webdav: bool, + + /// Show served file size in exact bytes. + #[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 |