diff options
author | Gaurav <allmanpride@gmail.com> | 2022-08-03 01:45:56 +0000 |
---|---|---|
committer | Gaurav <allmanpride@gmail.com> | 2022-08-14 00:03:55 +0000 |
commit | bd6ae43592df50244c6fde84e27a7f51dbe7d77f (patch) | |
tree | 408826f72f1ceb44241fbb9b3113cbd4841fb22b | |
parent | Add support for readme rendering (diff) | |
download | miniserve-bd6ae43592df50244c6fde84e27a7f51dbe7d77f.tar.gz miniserve-bd6ae43592df50244c6fde84e27a7f51dbe7d77f.zip |
Add `--readme` flag to cli
Diffstat (limited to '')
-rw-r--r-- | src/args.rs | 4 | ||||
-rw-r--r-- | src/config.rs | 4 | ||||
-rw-r--r-- | src/listing.rs | 4 |
3 files changed, 10 insertions, 2 deletions
diff --git a/src/args.rs b/src/args.rs index 687649d..9674651 100644 --- a/src/args.rs +++ b/src/args.rs @@ -197,6 +197,10 @@ pub struct CliArgs { #[cfg(feature = "tls")] #[clap(long = "tls-key", requires = "tls-cert", value_hint = ValueHint::FilePath)] pub tls_key: Option<PathBuf>, + + /// Enable readme redering in directories + #[clap(long = "readme")] + pub readme: bool, } /// Checks wether an interface is valid, i.e. it can be parsed into an IP address diff --git a/src/config.rs b/src/config.rs index ec7ec66..9dddeb9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -123,6 +123,9 @@ pub struct MiniserveConfig { /// If enabled, display a wget command to recursively download the current directory pub show_wget_footer: bool, + /// If enabled, render the readme from the current directory + pub readme: bool, + /// If set, use provided rustls config for TLS #[cfg(feature = "tls")] pub tls_rustls_config: Option<rustls::ServerConfig>, @@ -256,6 +259,7 @@ impl MiniserveConfig { hide_version_footer: args.hide_version_footer, hide_theme_selector: args.hide_theme_selector, show_wget_footer: args.show_wget_footer, + readme: args.readme, tls_rustls_config: tls_rustls_server_config, }) } diff --git a/src/listing.rs b/src/listing.rs index 3c77c14..458744c 100644 --- a/src/listing.rs +++ b/src/listing.rs @@ -283,8 +283,8 @@ pub fn directory_listing( last_modification_date, symlink_dest, )); - // TODO: Pattern match, or user arg for readme name? - if file_name.to_lowercase() == "readme.md"{ + // TODO: Pattern match? + if conf.readme && file_name.to_lowercase() == "readme.md"{ readme = Some(file_name); } } |