Allow boolean flags to be repeated
bat prepends the arguments from its config file to the command line, so a user who has `--show-all` in their config and also types `-A` passes the flag twice, and clap rejects that with "the argument '--show-all' cannot be used multiple times" and exit code 2. The file is never displayed. `--plain`, `--number`, `--number-nonblank`, `--force-colorization` and `--no-paging` already avoid this by overriding themselves. The same is now done for the eight remaining flags that affect how a file is displayed: --show-all, --diff, --chop-long-lines, --squeeze-blank, --unbuffered, --quiet-empty, --no-custom-assets and --set-terminal-title. Repeating a flag produces byte-identical output to giving it once, and --show-all still conflicts with --language as before.
This commit is contained in:
1 parent
16b5f99d16
commit
cf72a432ac
4 files changed
+34
No files matched your search
@@ -646,6 +646,30 @@ fn piped_output_with_default_style_flag() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn repeated_boolean_flag_is_accepted() {
|
||||
// A flag in the config file is prepended to the command line, so a user
|
||||
// who has `--show-all` in their config and also types `-A` ends up passing
|
||||
// it twice. That must not be an error.
|
||||
bat()
|
||||
.arg("empty_lines.txt")
|
||||
.arg("--show-all")
|
||||
.arg("--show-all")
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn boolean_flag_in_config_and_on_command_line() {
|
||||
bat_with_config()
|
||||
.env("BAT_CONFIG_PATH", "bat-show-all.conf")
|
||||
.arg("empty_lines.txt")
|
||||
.arg("--show-all")
|
||||
.arg("--paging=never")
|
||||
.assert()
|
||||
.success();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn squeeze_blank() {
|
||||
bat()
|
||||
|
||||
Reference in new issue
Block a user