on master help sign in
Merge pull request #1082 from LordFlashmeow/master
58dcabfDavid Peter
CHANGELOG.md+1
@@ -3,6 +3,7 @@
3## Features
3## Features
4
4
5- Added support for the `NO_COLOR` environment variable, see #1021 and #1031 (@eth-p)
5- Added support for the `NO_COLOR` environment variable, see #1021 and #1031 (@eth-p)
6+- Added `-P` short flag to disable paging, revised man page description, see #1075 and #1082 (@LordFlashmeow)
6
7
7## Bugfixes
8## Bugfixes
8
9
assets/completions/bat.fish.in+2
@@ -52,6 +52,8 @@ complete -c {{PROJECT_EXECUTABLE}} -l paging -xka "auto never always" -d "Specif
52
52
53complete -c {{PROJECT_EXECUTABLE}} -s p -l plain -d "Only show plain style, no decorations. Alias for '--style=plain'" -n "not __fish_seen_subcommand_from cache"
53complete -c {{PROJECT_EXECUTABLE}} -s p -l plain -d "Only show plain style, no decorations. Alias for '--style=plain'" -n "not __fish_seen_subcommand_from cache"
54
54
55+complete -c {{PROJECT_EXECUTABLE}} -s P -d "Disable paging. Alias for '--paging=never'" -n "not __fish_seen_subcommand_from cache"
56+
55complete -c {{PROJECT_EXECUTABLE}} -s A -l show-all -d "Show non-printable characters like space/tab/newline" -n "not __fish_seen_subcommand_from cache"
57complete -c {{PROJECT_EXECUTABLE}} -s A -l show-all -d "Show non-printable characters like space/tab/newline" -n "not __fish_seen_subcommand_from cache"
56
58
57complete -c {{PROJECT_EXECUTABLE}} -l style -xka "auto full plain changes header grid numbers" -d "Comma-separated list of style elements or presets to display with file contents" -n "not __fish_seen_subcommand_from cache"
59complete -c {{PROJECT_EXECUTABLE}} -l style -xka "auto full plain changes header grid numbers" -d "Comma-separated list of style elements or presets to display with file contents" -n "not __fish_seen_subcommand_from cache"
assets/manual/bat.1.in+5−6
@@ -89,15 +89,14 @@ values: *auto*, never, always.
89.HP
89.HP
90\fB\-\-paging\fR <when>
90\fB\-\-paging\fR <when>
91.IP
91.IP
92−Specify when to use the pager. To control which pager is used, set the PAGER or
92+Specify when to use the pager. To disable the pager, use \&'\-\-paging=never' or its alias,
93−BAT_PAGER environment variables (the latter takes precedence) or use the '\-\-pager'
93+\fB-P\fR. To disable the pager permanently, set BAT_PAGER to an empty string. To control
94−option. To disable the pager permanently, set BAT_PAGER to an empty string or set
95−\&'\-\-paging=never' in the configuration file. Possible values: *auto*, never, always.
94+which pager is used, see the '\-\-pager' option. Possible values: *auto*, never, always.
96.HP
95.HP
97\fB\-\-pager\fR <command>
96\fB\-\-pager\fR <command>
98.IP
97.IP
99−Determine which pager is used. This option will overwrite the PAGER and BAT_PAGER
98+Determine which pager is used. This option will override the PAGER and BAT_PAGER
100−environment variables. The default pager is 'less'. To disable the pager completely, use
99+environment variables. The default pager is 'less'. To control when the pager is used, see
101the '\-\-paging' option. Example: '\-\-pager "less \fB\-RF\fR"'.
100the '\-\-paging' option. Example: '\-\-pager "less \fB\-RF\fR"'.
102.HP
101.HP
103\fB\-m\fR, \fB\-\-map\-syntax\fR <glob-pattern:syntax-name>...
102\fB\-m\fR, \fB\-\-map\-syntax\fR <glob-pattern:syntax-name>...
src/bin/bat/app.rs+2
@@ -85,6 +85,8 @@ impl App {
85 if self.matches.occurrences_of("plain") > 1 {
85 if self.matches.occurrences_of("plain") > 1 {
86 // If we have -pp as an option when in auto mode, the pager should be disabled.
86 // If we have -pp as an option when in auto mode, the pager should be disabled.
87 PagingMode::Never
87 PagingMode::Never
88+ } else if self.matches.is_present("no-paging") {
89+ PagingMode::Never
88 } else if inputs.iter().any(Input::is_stdin) {
90 } else if inputs.iter().any(Input::is_stdin) {
89 // If we are reading from stdin, only enable paging if we write to an
91 // If we are reading from stdin, only enable paging if we write to an
90 // interactive terminal and if we do not *read* from an interactive
92 // interactive terminal and if we do not *read* from an interactive
src/bin/bat/clap_app.rs+18−12
@@ -265,16 +265,23 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
265 .possible_values(&["auto", "never", "always"])
265 .possible_values(&["auto", "never", "always"])
266 .default_value("auto")
266 .default_value("auto")
267 .hide_default_value(true)
267 .hide_default_value(true)
268− .help("Specify when to use the pager (*auto*, never, always).")
268+ .help("Specify when to use the pager, or use `-P` to disable (*auto*, never, always).")
269 .long_help(
269 .long_help(
270− "Specify when to use the pager. To control which pager \
270+ "Specify when to use the pager. To disable the pager, use \
271− is used, set the PAGER or BAT_PAGER environment \
271+ --paging=never' or its alias,'-P'. To disable the pager permanently, \
272− variables (the latter takes precedence) or use the '--pager' option. \
272+ set BAT_PAGER to an empty string. To control which pager is used, see the \
273− To disable the pager permanently, set BAT_PAGER to an empty string \
274− or set '--paging=never' in the configuration file. \
275− Possible values: *auto*, never, always.",
273+ '--pager' option. Possible values: *auto*, never, always."
276 ),
274 ),
277 )
275 )
276+ .arg(
277+ Arg::with_name("no-paging")
278+ .short("P")
279+ .alias("no-pager")
280+ .overrides_with("no-paging")
281+ .hidden(true)
282+ .hidden_short_help(true)
283+ .help("Alias for '--paging=never'")
284+ )
278 .arg(
285 .arg(
279 Arg::with_name("pager")
286 Arg::with_name("pager")
280 .long("pager")
287 .long("pager")
@@ -284,11 +291,10 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
284 .hidden_short_help(true)
291 .hidden_short_help(true)
285 .help("Determine which pager to use.")
292 .help("Determine which pager to use.")
286 .long_help(
293 .long_help(
287− "Determine which pager is used. This option will overwrite \
294+ "Determine which pager is used. This option will override the \
288− the PAGER and BAT_PAGER environment variables. The default \
295+ PAGER and BAT_PAGER environment variables. The default pager is 'less'. \
289− pager is 'less'. To disable the pager completely, use the \
290− '--paging' option. \
296+ To control when the pager is used, see the '--paging' option. \
291− Example: '--pager \"less -RF\"'.",
297+ Example: '--pager \"less -RF\"'."
292 ),
298 ),
293 )
299 )
294 .arg(
300 .arg(
tests/integration_tests.rs+23
@@ -405,6 +405,29 @@ fn pager_disable() {
405 .stdout(predicate::eq("hello world\n").normalize());
405 .stdout(predicate::eq("hello world\n").normalize());
406}
406}
407
407
408+#[test]
409+fn alias_pager_disable() {
410+ bat()
411+ .env("PAGER", "echo other-pager")
412+ .arg("-P")
413+ .arg("test.txt")
414+ .assert()
415+ .success()
416+ .stdout(predicate::eq("hello world\n").normalize());
417+}
418+
419+#[test]
420+fn alias_pager_disable_long_overrides_short() {
421+ bat()
422+ .env("PAGER", "echo pager-output")
423+ .arg("-P")
424+ .arg("--paging=always")
425+ .arg("test.txt")
426+ .assert()
427+ .success()
428+ .stdout(predicate::eq("pager-output\n").normalize());
429+}
430+
408#[test]
431#[test]
409fn config_location_test() {
432fn config_location_test() {
410 bat_with_config()
433 bat_with_config()