From 0304ea92390c06ccbbd7d29a88ecedc9718d72c2 Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Wed, 3 Apr 2019 20:07:33 +0200 Subject: Added CLI argument to set default theme --- src/args.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/args.rs') diff --git a/src/args.rs b/src/args.rs index 4f0dbf7..bcee0bc 100644 --- a/src/args.rs +++ b/src/args.rs @@ -3,6 +3,7 @@ use std::path::PathBuf; use structopt::StructOpt; use crate::auth; +use crate::themes; /// Possible characters for random routes const ROUTE_ALPHABET: [char; 16] = [ @@ -47,6 +48,18 @@ struct CLIArgs { /// Do not follow symbolic links #[structopt(short = "P", long = "no-symlinks")] no_symlinks: bool, + + /// Default color scheme + #[structopt( + short = "c", + long = "color-scheme", + default_value = "Squirrel", + raw( + possible_values = "&themes::ColorScheme::variants()", + case_insensitive = "true", + ) + )] + color_scheme: themes::ColorScheme, } /// Checks wether an interface is valid, i.e. it can be parsed into an IP address @@ -89,6 +102,8 @@ pub fn parse_args() -> crate::MiniserveConfig { None }; + let default_color_scheme = args.color_scheme; + let path_explicitly_chosen = args.path.is_some(); crate::MiniserveConfig { @@ -100,5 +115,6 @@ pub fn parse_args() -> crate::MiniserveConfig { path_explicitly_chosen, no_symlinks: args.no_symlinks, random_route, + default_color_scheme, } } -- cgit v1.2.3 From bbdafc3e121942c95ba81db1cba30fe438d88dfb Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Sun, 7 Apr 2019 13:27:25 +0200 Subject: Use strum to reduce boilerplate on ColorScheme enum + removed useless Debug derives --- src/args.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/args.rs') diff --git a/src/args.rs b/src/args.rs index 3e54d08..516e0b6 100644 --- a/src/args.rs +++ b/src/args.rs @@ -10,7 +10,7 @@ const ROUTE_ALPHABET: [char; 16] = [ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 'b', 'c', 'd', 'e', 'f', ]; -#[derive(StructOpt, Debug)] +#[derive(StructOpt)] #[structopt( name = "miniserve", raw(global_settings = "&[structopt::clap::AppSettings::ColoredHelp]") -- cgit v1.2.3