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:
LOG committed 2026-09-04 18:01:33 +08:00
1 parent 16b5f99d16
commit cf72a432ac
4 files changed
+34

No files matched your search

+1
View File
@@ -25,6 +25,7 @@
- Syntax highlighting for Python files using uv as script runner in shebang #3689 (@janlarres)
## Bugfixes
- Allow boolean flags to be given more than once, so that a flag set in the config file can also be passed on the command line without erroring, see #3912 (@logarithmone1128)
- Use parsed CLI arguments to detect number flags, see #3908 (@cuishuang)
- Detect binary content beyond the first line, preventing encrypted files with early line breaks from being treated as text. Closes #3554, see #3877 (@Matei02355)
- Use the last occurrence of numbering and plain flags in combined short arguments, see #3897 (@cuishuang)