Skip to content

Commit 7f5c074

Browse files
committed
argv: add several hidden flags
This adds hidden counter-flags for the following: -L/--follow [--no-follow] --hidden [--no-hidden] --no-ignore [--ignore] --no-ignore-parent [--ignore-parent] --no-ignore-vcs [--ignore-vcs] --no-messages [--messages] --search-zip [--no-search-zip] --sort-files [--no-sort-files] --text [--no-text] In the above list, the counter-flags are in brackets. While these flags are hidden, we document the counter-flags in the documentation for the flags they are countering.
1 parent 874f0b9 commit 7f5c074

1 file changed

Lines changed: 81 additions & 9 deletions

File tree

src/app.rs

Lines changed: 81 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -884,9 +884,17 @@ fn flag_follow(args: &mut Vec<RGArg>) {
884884
When this flag is enabled, ripgrep will follow symbolic links while traversing
885885
directories. This is disabled by default. Note that ripgrep will check for
886886
symbolic link loops and report errors if it finds one.
887+
888+
This flag can be disabled with --no-follow.
887889
");
888890
let arg = RGArg::switch("follow").short("L")
889-
.help(SHORT).long_help(LONG);
891+
.help(SHORT).long_help(LONG)
892+
.overrides("no-follow");
893+
args.push(arg);
894+
895+
let arg = RGArg::switch("no-follow")
896+
.hidden()
897+
.overrides("follow");
890898
args.push(arg);
891899
}
892900

@@ -939,9 +947,17 @@ fn flag_hidden(args: &mut Vec<RGArg>) {
939947
Search hidden files and directories. By default, hidden files and directories
940948
are skipped. Note that if a hidden file or a directory is whitelisted in an
941949
ignore file, then it will be searched even if this flag isn't provided.
950+
951+
This flag can be disabled with --no-hidden.
942952
");
943953
let arg = RGArg::switch("hidden")
944-
.help(SHORT).long_help(LONG);
954+
.help(SHORT).long_help(LONG)
955+
.overrides("no-hidden");
956+
args.push(arg);
957+
958+
let arg = RGArg::switch("no-hidden")
959+
.hidden()
960+
.overrides("hidden");
945961
args.push(arg);
946962
}
947963

@@ -1164,19 +1180,35 @@ fn flag_no_ignore(args: &mut Vec<RGArg>) {
11641180
const LONG: &str = long!("\
11651181
Don't respect ignore files (.gitignore, .ignore, etc.). This implies
11661182
--no-ignore-parent and --no-ignore-vcs.
1183+
1184+
This flag can be disabled with the --ignore flag.
11671185
");
11681186
let arg = RGArg::switch("no-ignore")
1169-
.help(SHORT).long_help(LONG);
1187+
.help(SHORT).long_help(LONG)
1188+
.overrides("ignore");
1189+
args.push(arg);
1190+
1191+
let arg = RGArg::switch("ignore")
1192+
.hidden()
1193+
.overrides("no-ignore");
11701194
args.push(arg);
11711195
}
11721196

11731197
fn flag_no_ignore_parent(args: &mut Vec<RGArg>) {
11741198
const SHORT: &str = "Don't respect ignore files in parent directories.";
11751199
const LONG: &str = long!("\
11761200
Don't respect ignore files (.gitignore, .ignore, etc.) in parent directories.
1201+
1202+
This flag can be disabled with the --ignore-parent flag.
11771203
");
11781204
let arg = RGArg::switch("no-ignore-parent")
1179-
.help(SHORT).long_help(LONG);
1205+
.help(SHORT).long_help(LONG)
1206+
.overrides("ignore-parent");
1207+
args.push(arg);
1208+
1209+
let arg = RGArg::switch("ignore-parent")
1210+
.hidden()
1211+
.overrides("no-ignore-parent");
11801212
args.push(arg);
11811213
}
11821214

@@ -1186,9 +1218,17 @@ fn flag_no_ignore_vcs(args: &mut Vec<RGArg>) {
11861218
Don't respect version control ignore files (.gitignore, etc.). This implies
11871219
--no-ignore-parent for VCS files. Note that .ignore files will continue to be
11881220
respected.
1221+
1222+
This flag can be disabled with the --ignore-vcs flag.
11891223
");
11901224
let arg = RGArg::switch("no-ignore-vcs")
1191-
.help(SHORT).long_help(LONG);
1225+
.help(SHORT).long_help(LONG)
1226+
.overrides("ignore-vcs");
1227+
args.push(arg);
1228+
1229+
let arg = RGArg::switch("ignore-vcs")
1230+
.hidden()
1231+
.overrides("no-ignore-vcs");
11921232
args.push(arg);
11931233
}
11941234

@@ -1197,9 +1237,17 @@ fn flag_no_messages(args: &mut Vec<RGArg>) {
11971237
const LONG: &str = long!("\
11981238
Suppress all error messages. This provides the same behavior as redirecting
11991239
stderr to /dev/null on Unix-like systems.
1240+
1241+
This flag can be disabled with the --messages flag.
12001242
");
12011243
let arg = RGArg::switch("no-messages")
1202-
.help(SHORT).long_help(LONG);
1244+
.help(SHORT).long_help(LONG)
1245+
.overrides("messages");
1246+
args.push(arg);
1247+
1248+
let arg = RGArg::switch("messages")
1249+
.hidden()
1250+
.overrides("no-messages");
12031251
args.push(arg);
12041252
}
12051253

@@ -1347,9 +1395,17 @@ fn flag_search_zip(args: &mut Vec<RGArg>) {
13471395
Search in compressed files. Currently gz, bz2, xz, and lzma files are
13481396
supported. This option expects the decompression binaries to be available in
13491397
your PATH.
1398+
1399+
This flag can be disabled with --no-search-zip.
13501400
");
13511401
let arg = RGArg::switch("search-zip").short("z")
1352-
.help(SHORT).long_help(LONG);
1402+
.help(SHORT).long_help(LONG)
1403+
.overrides("no-search-zip");
1404+
args.push(arg);
1405+
1406+
let arg = RGArg::switch("no-search-zip")
1407+
.hidden()
1408+
.overrides("search-zip");
13531409
args.push(arg);
13541410
}
13551411

@@ -1373,9 +1429,17 @@ fn flag_sort_files(args: &mut Vec<RGArg>) {
13731429
const LONG: &str = long!("\
13741430
Sort results by file path. Note that this currently disables all parallelism
13751431
and runs search in a single thread.
1432+
1433+
This flag can be disabled with --no-sort-files.
13761434
");
13771435
let arg = RGArg::switch("sort-files")
1378-
.help(SHORT).long_help(LONG);
1436+
.help(SHORT).long_help(LONG)
1437+
.overrides("no-sort-files");
1438+
args.push(arg);
1439+
1440+
let arg = RGArg::switch("no-sort-files")
1441+
.hidden()
1442+
.overrides("sort-files");
13791443
args.push(arg);
13801444
}
13811445

@@ -1393,9 +1457,17 @@ considered binary and search stops (unless this flag is present).
13931457
13941458
Note that when the `-u/--unrestricted` flag is provided for a third time, then
13951459
this flag is automatically enabled.
1460+
1461+
This flag can be disabled with --no-text.
13961462
");
13971463
let arg = RGArg::switch("text").short("a")
1398-
.help(SHORT).long_help(LONG);
1464+
.help(SHORT).long_help(LONG)
1465+
.overrides("no-text");
1466+
args.push(arg);
1467+
1468+
let arg = RGArg::switch("no-text")
1469+
.hidden()
1470+
.overrides("text");
13991471
args.push(arg);
14001472
}
14011473

0 commit comments

Comments
 (0)