From da67063bcc3cea664608adcc860fc40f34500507 Mon Sep 17 00:00:00 2001 From: Jose Quintana Date: Wed, 19 May 2021 11:32:26 +0200 Subject: [PATCH] refactor: boolean literal parsing for --directory-listing argument --- src/config.rs | 9 +++++++-- src/server.rs | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index 3481560..6bbda94 100644 --- a/src/config.rs +++ b/src/config.rs @@ -68,7 +68,12 @@ pub struct Config { /// Specify the file path to read the private key. pub http2_tls_key: String, - #[structopt(long, short = "z", env = "SERVER_DIRECTORY_LISTING")] + #[structopt( + long, + short = "z", + parse(try_from_str), + env = "SERVER_DIRECTORY_LISTING" + )] /// Enable directory listing for all requests ending with the slash character (‘/’). - pub directory_listing: Option, + pub directory_listing: bool, } diff --git a/src/server.rs b/src/server.rs index ae40d51..c04fe51 100644 --- a/src/server.rs +++ b/src/server.rs @@ -76,7 +76,7 @@ impl Server { // TODO: CORS support // Directory listing option - let dir_listing = opts.directory_listing.unwrap_or_default(); + let dir_listing = opts.directory_listing; // Spawn a new Tokio asynchronous server task with its given options let threads = self.threads; -- libgit2 1.7.2