diff options
Diffstat (limited to 'src/args.rs')
-rw-r--r-- | src/args.rs | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/args.rs b/src/args.rs index f7b42f1..c78e08c 100644 --- a/src/args.rs +++ b/src/args.rs @@ -41,6 +41,14 @@ pub struct CliArgs { #[arg(long, requires = "index", env = "MINISERVE_SPA")] pub spa: bool, + /// Activate Pretty URLs mode + /// + /// This will cause the server to serve the equivalent `.html` file indicated by the path. + /// + /// `/about` will try to find `about.html` and serve it. + #[arg(long, env = "MINISERVE_PRETTY_URLS")] + pub pretty_urls: bool, + /// Port to use #[arg( short = 'p', @@ -60,7 +68,9 @@ pub struct CliArgs { )] pub interfaces: Vec<IpAddr>, - /// Set authentication. Currently supported formats: + /// Set authentication + /// + /// Currently supported formats: /// username:password, username:sha256:hash, username:sha512:hash /// (e.g. joe:123, joe:sha256:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3) #[arg( @@ -68,10 +78,21 @@ pub struct CliArgs { long = "auth", value_parser(parse_auth), num_args(1), - env = "MINISERVE_AUTH" + env = "MINISERVE_AUTH", + verbatim_doc_comment )] pub auth: Vec<auth::RequiredAuth>, + /// Read authentication values from a file + /// + /// Example file content: + /// + /// joe:123 + /// bob:sha256:a665a45920422f9d417e4867efdc4fb8a04a1f3fff1fa07e998e86f7f7a27ae3 + /// bill: + #[arg(long, value_hint = ValueHint::FilePath, env = "MINISERVE_AUTH_FILE", verbatim_doc_comment)] + pub auth_file: Option<PathBuf>, + /// Use a specific route prefix #[arg(long = "route-prefix", env = "MINISERVE_ROUTE_PREFIX")] pub route_prefix: Option<String>, @@ -241,7 +262,7 @@ fn parse_interface(src: &str) -> Result<IpAddr, std::net::AddrParseError> { } /// Parse authentication requirement -fn parse_auth(src: &str) -> Result<auth::RequiredAuth, ContextualError> { +pub fn parse_auth(src: &str) -> Result<auth::RequiredAuth, ContextualError> { let mut split = src.splitn(3, ':'); let invalid_auth_format = Err(ContextualError::InvalidAuthFormat); |