mirror of
https://github.com/sharkdp/fd
synced 2024-11-05 16:58:21 +00:00
Use overrides_with to clean up opposing arg logic
This commit is contained in:
parent
8da936abd8
commit
3ebd78cf02
2 changed files with 18 additions and 21 deletions
11
src/app.rs
11
src/app.rs
|
@ -32,7 +32,7 @@ pub fn build_app() -> App<'static, 'static> {
|
|||
.arg(
|
||||
Arg::with_name("no-hidden")
|
||||
.long("no-hidden")
|
||||
.overrides_with("no-hidden")
|
||||
.overrides_with("hidden")
|
||||
.hidden(true)
|
||||
.long_help(
|
||||
"Overrides --hidden.",
|
||||
|
@ -53,7 +53,7 @@ pub fn build_app() -> App<'static, 'static> {
|
|||
.arg(
|
||||
Arg::with_name("ignore")
|
||||
.long("ignore")
|
||||
.overrides_with("ignore")
|
||||
.overrides_with("no-ignore")
|
||||
.hidden(true)
|
||||
.long_help(
|
||||
"Overrides --no-ignore.",
|
||||
|
@ -72,7 +72,7 @@ pub fn build_app() -> App<'static, 'static> {
|
|||
.arg(
|
||||
Arg::with_name("ignore-vcs")
|
||||
.long("ignore-vcs")
|
||||
.overrides_with("ignore-vcs")
|
||||
.overrides_with("no-ignore-vcs")
|
||||
.hidden(true)
|
||||
.long_help(
|
||||
"Overrides --no-ignore-vcs.",
|
||||
|
@ -88,6 +88,7 @@ pub fn build_app() -> App<'static, 'static> {
|
|||
Arg::with_name("rg-alias-hidden-ignore")
|
||||
.short("u")
|
||||
.long("unrestricted")
|
||||
.overrides_with_all(&["ignore", "no-hidden"])
|
||||
.multiple(true)
|
||||
.hidden_short_help(true)
|
||||
.long_help(
|
||||
|
@ -165,7 +166,7 @@ pub fn build_app() -> App<'static, 'static> {
|
|||
.arg(
|
||||
Arg::with_name("relative-path")
|
||||
.long("relative-path")
|
||||
.overrides_with("relative-path")
|
||||
.overrides_with("absolute-path")
|
||||
.hidden(true)
|
||||
.long_help(
|
||||
"Overrides --absolute-path.",
|
||||
|
@ -200,7 +201,7 @@ pub fn build_app() -> App<'static, 'static> {
|
|||
.arg(
|
||||
Arg::with_name("no-follow")
|
||||
.long("no-follow")
|
||||
.overrides_with("no-follow")
|
||||
.overrides_with("follow")
|
||||
.hidden(true)
|
||||
.long_help(
|
||||
"Overrides --follow.",
|
||||
|
|
28
src/main.rs
28
src/main.rs
|
@ -116,7 +116,7 @@ fn run() -> Result<ExitCode> {
|
|||
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
|
||||
.iter()
|
||||
.map(|path_buffer| {
|
||||
|
@ -333,21 +333,17 @@ fn run() -> Result<ExitCode> {
|
|||
let config = Options {
|
||||
case_sensitive,
|
||||
search_full_path: matches.is_present("full-path"),
|
||||
ignore_hidden: matches.is_present("no-hidden")
|
||||
|| !(matches.is_present("hidden")
|
||||
|| matches.occurrences_of("rg-alias-hidden-ignore") >= 2),
|
||||
read_fdignore: matches.is_present("ignore")
|
||||
|| !(matches.is_present("no-ignore") || matches.is_present("rg-alias-hidden-ignore")),
|
||||
read_vcsignore: matches.is_present("ignore") || matches.is_present("ignore-vcs") || {
|
||||
!(matches.is_present("no-ignore")
|
||||
|| matches.is_present("rg-alias-hidden-ignore")
|
||||
|| matches.is_present("no-ignore-vcs"))
|
||||
},
|
||||
read_global_ignore: matches.is_present("ignore")
|
||||
|| !(matches.is_present("no-ignore")
|
||||
|| matches.is_present("rg-alias-hidden-ignore")
|
||||
|| matches.is_present("no-global-ignore-file")),
|
||||
follow_links: matches.is_present("follow") && !matches.is_present("no-follow"),
|
||||
ignore_hidden: !(matches.is_present("hidden")
|
||||
|| matches.occurrences_of("rg-alias-hidden-ignore") >= 2),
|
||||
read_fdignore: !(matches.is_present("no-ignore")
|
||||
|| matches.is_present("rg-alias-hidden-ignore")),
|
||||
read_vcsignore: !(matches.is_present("no-ignore")
|
||||
|| matches.is_present("rg-alias-hidden-ignore")
|
||||
|| matches.is_present("no-ignore-vcs")),
|
||||
read_global_ignore: !(matches.is_present("no-ignore")
|
||||
|| matches.is_present("rg-alias-hidden-ignore")
|
||||
|| matches.is_present("no-global-ignore-file")),
|
||||
follow_links: matches.is_present("follow"),
|
||||
one_file_system: matches.is_present("one-file-system"),
|
||||
null_separator: matches.is_present("null_separator"),
|
||||
max_depth: matches
|
||||
|
|
Loading…
Reference in a new issue