Skip to content

Commit

Permalink
Make --no-paging/-P override --paging=... if passed as a later …
Browse files Browse the repository at this point in the history
…arg (#2201)

* Make the no-paging option override earlier paging options

* Update CHANGELOG.md

Co-authored-by: Martin Nordholts <enselic@gmail.com>
  • Loading branch information
themkat and Enselic committed Aug 14, 2022
1 parent 02a9d19 commit 9c7ca33
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
## Bugfixes

- Prevent fork nightmare with `PAGER=batcat`. See #2235 (@johnmatthiggins)
- Make `--no-paging`/`-P` override `--paging=...` if passed as a later arg, see #2201 (@themkat)

## Other

Expand Down
1 change: 1 addition & 0 deletions src/bin/bat/clap_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
Arg::with_name("paging")
.long("paging")
.overrides_with("paging")
.overrides_with("no-paging")
.takes_value(true)
.value_name("when")
.possible_values(&["auto", "never", "always"])
Expand Down
12 changes: 12 additions & 0 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,18 @@ fn alias_pager_disable_long_overrides_short() {
.stdout(predicate::eq("pager-output\n").normalize());
}

#[test]
fn disable_pager_if_disable_paging_flag_comes_after_paging() {
bat()
.env("PAGER", "echo pager-output")
.arg("--paging=always")
.arg("-P")
.arg("test.txt")
.assert()
.success()
.stdout(predicate::eq("hello world\n").normalize());
}

#[test]
fn pager_failed_to_parse() {
bat()
Expand Down

0 comments on commit 9c7ca33

Please sign in to comment.