mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-09 00:59:02 +03:00
chore: refactor clap multiple_occurrences and multiple_values (#130)
This commit is contained in:
17
src/args.rs
17
src/args.rs
@@ -1,4 +1,4 @@
|
||||
use clap::{value_parser, AppSettings, Arg, ArgMatches, Command};
|
||||
use clap::{value_parser, AppSettings, Arg, ArgAction, ArgMatches, Command};
|
||||
use clap_complete::{generate, Generator, Shell};
|
||||
#[cfg(feature = "tls")]
|
||||
use rustls::{Certificate, PrivateKey};
|
||||
@@ -30,7 +30,8 @@ pub fn build_cli() -> Command<'static> {
|
||||
.long("bind")
|
||||
.help("Specify bind address")
|
||||
.multiple_values(true)
|
||||
.multiple_occurrences(true)
|
||||
.value_delimiter(',')
|
||||
.action(ArgAction::Append)
|
||||
.value_name("addr"),
|
||||
)
|
||||
.arg(
|
||||
@@ -56,7 +57,10 @@ pub fn build_cli() -> Command<'static> {
|
||||
.arg(
|
||||
Arg::new("hidden")
|
||||
.long("hidden")
|
||||
.help("Hide paths from directory listings, separated by `,`")
|
||||
.help("Hide paths from directory listings")
|
||||
.multiple_values(true)
|
||||
.value_delimiter(',')
|
||||
.action(ArgAction::Append)
|
||||
.value_name("value"),
|
||||
)
|
||||
.arg(
|
||||
@@ -64,8 +68,9 @@ pub fn build_cli() -> Command<'static> {
|
||||
.short('a')
|
||||
.long("auth")
|
||||
.help("Add auth for path")
|
||||
.action(ArgAction::Append)
|
||||
.multiple_values(true)
|
||||
.multiple_occurrences(true)
|
||||
.value_delimiter(',')
|
||||
.value_name("rule"),
|
||||
)
|
||||
.arg(
|
||||
@@ -207,8 +212,8 @@ impl Args {
|
||||
format!("/{}/", &encode_uri(&path_prefix))
|
||||
};
|
||||
let hidden: Vec<String> = matches
|
||||
.value_of("hidden")
|
||||
.map(|v| v.split(',').map(|x| x.to_string()).collect())
|
||||
.values_of("hidden")
|
||||
.map(|v| v.map(|v| v.to_string()).collect())
|
||||
.unwrap_or_default();
|
||||
let enable_cors = matches.is_present("enable-cors");
|
||||
let auth: Vec<&str> = matches
|
||||
|
||||
Reference in New Issue
Block a user