diff options
Diffstat (limited to 'cli/flags.rs')
-rw-r--r-- | cli/flags.rs | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/cli/flags.rs b/cli/flags.rs index c703089f9..ef3f75e23 100644 --- a/cli/flags.rs +++ b/cli/flags.rs @@ -1173,16 +1173,15 @@ fn reload_arg<'a, 'b>() -> Arg<'a, 'b> { } fn reload_arg_parse(flags: &mut Flags, matches: &ArgMatches) { - if matches.is_present("reload") { - if matches.value_of("reload").is_some() { - let cache_bl = matches.values_of("reload").unwrap(); - let raw_cache_blacklist: Vec<String> = - cache_bl.map(std::string::ToString::to_string).collect(); + if let Some(cache_bl) = matches.values_of("reload") { + let raw_cache_blacklist: Vec<String> = + cache_bl.map(std::string::ToString::to_string).collect(); + if raw_cache_blacklist.is_empty() { + flags.reload = true; + } else { flags.cache_blacklist = resolve_urls(raw_cache_blacklist); debug!("cache blacklist: {:#?}", &flags.cache_blacklist); flags.reload = false; - } else { - flags.reload = true; } } } @@ -1235,39 +1234,40 @@ fn no_remote_arg_parse(flags: &mut Flags, matches: &clap::ArgMatches) { } fn permission_args_parse(flags: &mut Flags, matches: &clap::ArgMatches) { - if matches.is_present("allow-read") { - if matches.value_of("allow-read").is_some() { - let read_wl = matches.values_of("allow-read").unwrap(); - let raw_read_whitelist: Vec<PathBuf> = - read_wl.map(PathBuf::from).collect(); + if let Some(read_wl) = matches.values_of("allow-read") { + let raw_read_whitelist: Vec<PathBuf> = read_wl.map(PathBuf::from).collect(); + + if raw_read_whitelist.is_empty() { + flags.allow_read = true; + } else { flags.read_whitelist = resolve_fs_whitelist(&raw_read_whitelist); debug!("read whitelist: {:#?}", &flags.read_whitelist); - } else { - flags.allow_read = true; } } - if matches.is_present("allow-write") { - if matches.value_of("allow-write").is_some() { - let write_wl = matches.values_of("allow-write").unwrap(); - let raw_write_whitelist: Vec<PathBuf> = - write_wl.map(PathBuf::from).collect(); + + if let Some(write_wl) = matches.values_of("allow-write") { + let raw_write_whitelist: Vec<PathBuf> = + write_wl.map(PathBuf::from).collect(); + + if raw_write_whitelist.is_empty() { + flags.allow_write = true; + } else { flags.write_whitelist = resolve_fs_whitelist(&raw_write_whitelist); debug!("write whitelist: {:#?}", &flags.write_whitelist); - } else { - flags.allow_write = true; } } - if matches.is_present("allow-net") { - if matches.value_of("allow-net").is_some() { - let net_wl = matches.values_of("allow-net").unwrap(); - let raw_net_whitelist = - net_wl.map(std::string::ToString::to_string).collect(); + + if let Some(net_wl) = matches.values_of("allow-net") { + let raw_net_whitelist: Vec<String> = + net_wl.map(std::string::ToString::to_string).collect(); + if raw_net_whitelist.is_empty() { + flags.allow_net = true; + } else { flags.net_whitelist = resolve_hosts(raw_net_whitelist); debug!("net whitelist: {:#?}", &flags.net_whitelist); - } else { - flags.allow_net = true; } } + if matches.is_present("allow-env") { flags.allow_env = true; } |