From 59c1dbf5fe36a6041783f25ee60800ba1601e3c3 Mon Sep 17 00:00:00 2001 From: Joe Wilm Date: Tue, 29 Aug 2017 09:26:52 -0700 Subject: [PATCH] Change CLI live-config-reload options into flags The previous format of --live-config-reload=VAL had a specific set of allowed values which may not immediately be obvious. Instead, there are now two flags which control the behavior: --live-config-reload --no-live-config-reload If a user tries to specify both, the option parsing will fail with this message: error: The argument '--no-live-config-reload' cannot be used with '--live-config-reload' --- src/cli.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index ea5610eb..f6013f51 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -63,9 +63,11 @@ impl Options { .help("Generates ref test")) .arg(Arg::with_name("live-config-reload") .long("live-config-reload") - .help("Live configuration reload") - .takes_value(true) - .use_delimiter(false)) + .help("Enable automatic config reloading")) + .arg(Arg::with_name("no-live-config-reload") + .long("no-live-config-reload") + .help("Disable automatic config reloading") + .conflicts_with("live-config-reload")) .arg(Arg::with_name("print-events") .long("print-events")) .arg(Arg::with_name("dimensions") @@ -114,12 +116,10 @@ impl Options { options.print_events = true; } - if let Some(val) = matches.value_of("live-config-reload") { - match val { - "y" | "yes" => options.live_config_reload = Some(true), - "n" | "no" => options.live_config_reload = Some(false), - _ => options.live_config_reload = None, - } + if matches.is_present("live-config-reload") { + options.live_config_reload = Some(true); + } else if matches.is_present("no-live-config-reload") { + options.live_config_reload = Some(false); } if let Some(mut dimensions) = matches.values_of("dimensions") {