diff options
author | Andrew Gallant <jamslam@gmail.com> | 2018-02-04 11:41:06 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2018-02-06 12:07:59 -0500 |
commit | 224c112e0509ab2aeb28de05efbbce9486a55eff (patch) | |
tree | a98c7285ac687ad29afae0c0016ec9ec84cd6d40 /src/app.rs | |
parent | 8cb5833ef9fd6c4c351d10a3e950339fa89adf49 (diff) |
argv: tweak the meaning of zero
This commit makes a small tweak to the --max-columns flag. Namely, if
the value of the flag is 0, then ripgrep behaves as-if the flag were
absent.
This is useful in the context of ripgrep reading configuration from the
environment. For example, an end user might set --max-columns=150, but we
should permit the user to disable this setting when needed. Using -M0 is
a nice way to do that.
We do this because a zero value for --max-columns isn't particularly
meaningful. We do leave the --max-count, --max-filesize and --maxdepth
flags alone though, since a zero value for those flags is potentially
meaningful. (--max-count even has tests for ripgrep's behavior when
given a value of 0.)
Diffstat (limited to 'src/app.rs')
-rw-r--r-- | src/app.rs | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -1034,6 +1034,8 @@ fn flag_max_columns(args: &mut Vec<RGArg>) { const LONG: &str = long!("\ Don't print lines longer than this limit in bytes. Longer lines are omitted, and only the number of matches in that line is printed. + +When this flag is omitted or is set to 0, then it has no effect. "); let arg = RGArg::flag("max-columns", "NUM").short("M") .help(SHORT).long_help(LONG) |