mirror of https://github.com/sharkdp/fd.git
Use overrides_with to clean up opposing arg logic
This commit is contained in:
parent
8da936abd8
commit
3ebd78cf02
11
src/app.rs
11
src/app.rs
|
@ -32,7 +32,7 @@ pub fn build_app() -> App<'static, 'static> {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("no-hidden")
|
Arg::with_name("no-hidden")
|
||||||
.long("no-hidden")
|
.long("no-hidden")
|
||||||
.overrides_with("no-hidden")
|
.overrides_with("hidden")
|
||||||
.hidden(true)
|
.hidden(true)
|
||||||
.long_help(
|
.long_help(
|
||||||
"Overrides --hidden.",
|
"Overrides --hidden.",
|
||||||
|
@ -53,7 +53,7 @@ pub fn build_app() -> App<'static, 'static> {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("ignore")
|
Arg::with_name("ignore")
|
||||||
.long("ignore")
|
.long("ignore")
|
||||||
.overrides_with("ignore")
|
.overrides_with("no-ignore")
|
||||||
.hidden(true)
|
.hidden(true)
|
||||||
.long_help(
|
.long_help(
|
||||||
"Overrides --no-ignore.",
|
"Overrides --no-ignore.",
|
||||||
|
@ -72,7 +72,7 @@ pub fn build_app() -> App<'static, 'static> {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("ignore-vcs")
|
Arg::with_name("ignore-vcs")
|
||||||
.long("ignore-vcs")
|
.long("ignore-vcs")
|
||||||
.overrides_with("ignore-vcs")
|
.overrides_with("no-ignore-vcs")
|
||||||
.hidden(true)
|
.hidden(true)
|
||||||
.long_help(
|
.long_help(
|
||||||
"Overrides --no-ignore-vcs.",
|
"Overrides --no-ignore-vcs.",
|
||||||
|
@ -88,6 +88,7 @@ pub fn build_app() -> App<'static, 'static> {
|
||||||
Arg::with_name("rg-alias-hidden-ignore")
|
Arg::with_name("rg-alias-hidden-ignore")
|
||||||
.short("u")
|
.short("u")
|
||||||
.long("unrestricted")
|
.long("unrestricted")
|
||||||
|
.overrides_with_all(&["ignore", "no-hidden"])
|
||||||
.multiple(true)
|
.multiple(true)
|
||||||
.hidden_short_help(true)
|
.hidden_short_help(true)
|
||||||
.long_help(
|
.long_help(
|
||||||
|
@ -165,7 +166,7 @@ pub fn build_app() -> App<'static, 'static> {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("relative-path")
|
Arg::with_name("relative-path")
|
||||||
.long("relative-path")
|
.long("relative-path")
|
||||||
.overrides_with("relative-path")
|
.overrides_with("absolute-path")
|
||||||
.hidden(true)
|
.hidden(true)
|
||||||
.long_help(
|
.long_help(
|
||||||
"Overrides --absolute-path.",
|
"Overrides --absolute-path.",
|
||||||
|
@ -200,7 +201,7 @@ pub fn build_app() -> App<'static, 'static> {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("no-follow")
|
Arg::with_name("no-follow")
|
||||||
.long("no-follow")
|
.long("no-follow")
|
||||||
.overrides_with("no-follow")
|
.overrides_with("follow")
|
||||||
.hidden(true)
|
.hidden(true)
|
||||||
.long_help(
|
.long_help(
|
||||||
"Overrides --follow.",
|
"Overrides --follow.",
|
||||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -116,7 +116,7 @@ fn run() -> Result<ExitCode> {
|
||||||
return Err(anyhow!("No valid search paths given."));
|
return Err(anyhow!("No valid search paths given."));
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches.is_present("absolute-path") && !matches.is_present("relative-path") {
|
if matches.is_present("absolute-path") {
|
||||||
search_paths = search_paths
|
search_paths = search_paths
|
||||||
.iter()
|
.iter()
|
||||||
.map(|path_buffer| {
|
.map(|path_buffer| {
|
||||||
|
@ -333,21 +333,17 @@ fn run() -> Result<ExitCode> {
|
||||||
let config = Options {
|
let config = Options {
|
||||||
case_sensitive,
|
case_sensitive,
|
||||||
search_full_path: matches.is_present("full-path"),
|
search_full_path: matches.is_present("full-path"),
|
||||||
ignore_hidden: matches.is_present("no-hidden")
|
ignore_hidden: !(matches.is_present("hidden")
|
||||||
|| !(matches.is_present("hidden")
|
|
||||||
|| matches.occurrences_of("rg-alias-hidden-ignore") >= 2),
|
|| matches.occurrences_of("rg-alias-hidden-ignore") >= 2),
|
||||||
read_fdignore: matches.is_present("ignore")
|
read_fdignore: !(matches.is_present("no-ignore")
|
||||||
|| !(matches.is_present("no-ignore") || matches.is_present("rg-alias-hidden-ignore")),
|
|| matches.is_present("rg-alias-hidden-ignore")),
|
||||||
read_vcsignore: matches.is_present("ignore") || matches.is_present("ignore-vcs") || {
|
read_vcsignore: !(matches.is_present("no-ignore")
|
||||||
!(matches.is_present("no-ignore")
|
|
||||||
|| matches.is_present("rg-alias-hidden-ignore")
|
|| matches.is_present("rg-alias-hidden-ignore")
|
||||||
|| matches.is_present("no-ignore-vcs"))
|
|| matches.is_present("no-ignore-vcs")),
|
||||||
},
|
read_global_ignore: !(matches.is_present("no-ignore")
|
||||||
read_global_ignore: matches.is_present("ignore")
|
|
||||||
|| !(matches.is_present("no-ignore")
|
|
||||||
|| matches.is_present("rg-alias-hidden-ignore")
|
|| matches.is_present("rg-alias-hidden-ignore")
|
||||||
|| matches.is_present("no-global-ignore-file")),
|
|| matches.is_present("no-global-ignore-file")),
|
||||||
follow_links: matches.is_present("follow") && !matches.is_present("no-follow"),
|
follow_links: matches.is_present("follow"),
|
||||||
one_file_system: matches.is_present("one-file-system"),
|
one_file_system: matches.is_present("one-file-system"),
|
||||||
null_separator: matches.is_present("null_separator"),
|
null_separator: matches.is_present("null_separator"),
|
||||||
max_depth: matches
|
max_depth: matches
|
||||||
|
|
Loading…
Reference in New Issue