mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-11-04 09:01:56 +00:00 
			
		
		
		
	Merge pull request #1082 from LordFlashmeow/master
Add alias for --paging=never
This commit is contained in:
		@@ -3,6 +3,7 @@
 | 
				
			|||||||
## Features
 | 
					## Features
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Added support for the `NO_COLOR` environment variable, see #1021 and #1031 (@eth-p)
 | 
					- Added support for the `NO_COLOR` environment variable, see #1021 and #1031 (@eth-p)
 | 
				
			||||||
 | 
					- Added `-P` short flag to disable paging, revised man page description, see #1075 and #1082 (@LordFlashmeow) 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Bugfixes
 | 
					## Bugfixes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								assets/completions/bat.fish.in
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								assets/completions/bat.fish.in
									
									
									
									
										vendored
									
									
								
							@@ -52,6 +52,8 @@ complete -c {{PROJECT_EXECUTABLE}} -l paging -xka "auto never always" -d "Specif
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
complete -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"
 | 
					complete -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"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					complete -c {{PROJECT_EXECUTABLE}} -s P -d "Disable paging. Alias for '--paging=never'" -n "not __fish_seen_subcommand_from cache"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
complete -c {{PROJECT_EXECUTABLE}} -s A -l show-all -d "Show non-printable characters like space/tab/newline" -n "not __fish_seen_subcommand_from cache"
 | 
					complete -c {{PROJECT_EXECUTABLE}} -s A -l show-all -d "Show non-printable characters like space/tab/newline" -n "not __fish_seen_subcommand_from cache"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
complete -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"
 | 
					complete -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"
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										11
									
								
								assets/manual/bat.1.in
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								assets/manual/bat.1.in
									
									
									
									
										vendored
									
									
								
							@@ -89,15 +89,14 @@ values: *auto*, never, always.
 | 
				
			|||||||
.HP
 | 
					.HP
 | 
				
			||||||
\fB\-\-paging\fR <when>
 | 
					\fB\-\-paging\fR <when>
 | 
				
			||||||
.IP
 | 
					.IP
 | 
				
			||||||
Specify when to use the pager. To control which pager is used, set the PAGER or
 | 
					Specify when to use the pager. To disable the pager, use \&'\-\-paging=never' or its alias,
 | 
				
			||||||
BAT_PAGER environment variables (the latter takes precedence) or use the '\-\-pager'
 | 
					\fB-P\fR. To disable the pager permanently, set BAT_PAGER to an empty string. To control
 | 
				
			||||||
option. To disable the pager permanently, set BAT_PAGER to an empty string or set
 | 
					which pager is used, see the '\-\-pager' option. Possible values: *auto*, never, always.
 | 
				
			||||||
\&'\-\-paging=never' in the configuration file. Possible values: *auto*, never, always.
 | 
					 | 
				
			||||||
.HP
 | 
					.HP
 | 
				
			||||||
\fB\-\-pager\fR <command>
 | 
					\fB\-\-pager\fR <command>
 | 
				
			||||||
.IP
 | 
					.IP
 | 
				
			||||||
Determine which pager is used. This option will overwrite the PAGER and BAT_PAGER
 | 
					Determine which pager is used. This option will override the PAGER and BAT_PAGER
 | 
				
			||||||
environment variables. The default pager is 'less'. To disable the pager completely, use
 | 
					environment variables. The default pager is 'less'. To control when the pager is used, see
 | 
				
			||||||
the '\-\-paging' option. Example: '\-\-pager "less \fB\-RF\fR"'.
 | 
					the '\-\-paging' option. Example: '\-\-pager "less \fB\-RF\fR"'.
 | 
				
			||||||
.HP
 | 
					.HP
 | 
				
			||||||
\fB\-m\fR, \fB\-\-map\-syntax\fR <glob-pattern:syntax-name>...
 | 
					\fB\-m\fR, \fB\-\-map\-syntax\fR <glob-pattern:syntax-name>...
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -85,6 +85,8 @@ impl App {
 | 
				
			|||||||
                if self.matches.occurrences_of("plain") > 1 {
 | 
					                if self.matches.occurrences_of("plain") > 1 {
 | 
				
			||||||
                    // If we have -pp as an option when in auto mode, the pager should be disabled.
 | 
					                    // If we have -pp as an option when in auto mode, the pager should be disabled.
 | 
				
			||||||
                    PagingMode::Never
 | 
					                    PagingMode::Never
 | 
				
			||||||
 | 
					                } else if self.matches.is_present("no-paging") {
 | 
				
			||||||
 | 
					                    PagingMode::Never
 | 
				
			||||||
                } else if inputs.iter().any(Input::is_stdin) {
 | 
					                } else if inputs.iter().any(Input::is_stdin) {
 | 
				
			||||||
                    // If we are reading from stdin, only enable paging if we write to an
 | 
					                    // If we are reading from stdin, only enable paging if we write to an
 | 
				
			||||||
                    // interactive terminal and if we do not *read* from an interactive
 | 
					                    // interactive terminal and if we do not *read* from an interactive
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -265,16 +265,23 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
 | 
				
			|||||||
                .possible_values(&["auto", "never", "always"])
 | 
					                .possible_values(&["auto", "never", "always"])
 | 
				
			||||||
                .default_value("auto")
 | 
					                .default_value("auto")
 | 
				
			||||||
                .hide_default_value(true)
 | 
					                .hide_default_value(true)
 | 
				
			||||||
                .help("Specify when to use the pager (*auto*, never, always).")
 | 
					                .help("Specify when to use the pager, or use `-P` to disable (*auto*, never, always).")
 | 
				
			||||||
                .long_help(
 | 
					                .long_help(
 | 
				
			||||||
                    "Specify when to use the pager. To control which pager \
 | 
					                    "Specify when to use the pager. To disable the pager, use \
 | 
				
			||||||
                     is used, set the PAGER or BAT_PAGER environment \
 | 
					                    --paging=never' or its alias,'-P'. To disable the pager permanently, \
 | 
				
			||||||
                     variables (the latter takes precedence) or use the '--pager' option. \
 | 
					                    set BAT_PAGER to an empty string. To control which pager is used, see the \
 | 
				
			||||||
                     To disable the pager permanently, set BAT_PAGER to an empty string \
 | 
					                    '--pager' option. Possible values: *auto*, never, always."
 | 
				
			||||||
                     or set '--paging=never' in the configuration file. \
 | 
					 | 
				
			||||||
                     Possible values: *auto*, never, always.",
 | 
					 | 
				
			||||||
                ),
 | 
					                ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					        .arg(
 | 
				
			||||||
 | 
					            Arg::with_name("no-paging")
 | 
				
			||||||
 | 
					                .short("P")
 | 
				
			||||||
 | 
					                .alias("no-pager")
 | 
				
			||||||
 | 
					                .overrides_with("no-paging")
 | 
				
			||||||
 | 
					                .hidden(true)
 | 
				
			||||||
 | 
					                .hidden_short_help(true)
 | 
				
			||||||
 | 
					                .help("Alias for '--paging=never'")
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
        .arg(
 | 
					        .arg(
 | 
				
			||||||
            Arg::with_name("pager")
 | 
					            Arg::with_name("pager")
 | 
				
			||||||
                .long("pager")
 | 
					                .long("pager")
 | 
				
			||||||
@@ -284,11 +291,10 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
 | 
				
			|||||||
                .hidden_short_help(true)
 | 
					                .hidden_short_help(true)
 | 
				
			||||||
                .help("Determine which pager to use.")
 | 
					                .help("Determine which pager to use.")
 | 
				
			||||||
                .long_help(
 | 
					                .long_help(
 | 
				
			||||||
                    "Determine which pager is used. This option will overwrite \
 | 
					                    "Determine which pager is used. This option will override the \
 | 
				
			||||||
                     the PAGER and BAT_PAGER environment variables. The default \
 | 
					                    PAGER and BAT_PAGER environment variables. The default pager is 'less'. \
 | 
				
			||||||
                     pager is 'less'. To disable the pager completely, use the \
 | 
					                    To control when the pager is used, see the '--paging' option. \
 | 
				
			||||||
                     '--paging' option. \
 | 
					                    Example: '--pager \"less -RF\"'."
 | 
				
			||||||
                     Example: '--pager \"less -RF\"'.",
 | 
					 | 
				
			||||||
                ),
 | 
					                ),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        .arg(
 | 
					        .arg(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -405,6 +405,29 @@ fn pager_disable() {
 | 
				
			|||||||
        .stdout(predicate::eq("hello world\n").normalize());
 | 
					        .stdout(predicate::eq("hello world\n").normalize());
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[test]
 | 
				
			||||||
 | 
					fn alias_pager_disable() {
 | 
				
			||||||
 | 
					    bat()
 | 
				
			||||||
 | 
					        .env("PAGER", "echo other-pager")
 | 
				
			||||||
 | 
					        .arg("-P")
 | 
				
			||||||
 | 
					        .arg("test.txt")
 | 
				
			||||||
 | 
					        .assert()
 | 
				
			||||||
 | 
					        .success()
 | 
				
			||||||
 | 
					        .stdout(predicate::eq("hello world\n").normalize());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#[test]
 | 
				
			||||||
 | 
					fn alias_pager_disable_long_overrides_short() {
 | 
				
			||||||
 | 
					    bat()
 | 
				
			||||||
 | 
					        .env("PAGER", "echo pager-output")
 | 
				
			||||||
 | 
					        .arg("-P")
 | 
				
			||||||
 | 
					        .arg("--paging=always")
 | 
				
			||||||
 | 
					        .arg("test.txt")
 | 
				
			||||||
 | 
					        .assert()
 | 
				
			||||||
 | 
					        .success()
 | 
				
			||||||
 | 
					        .stdout(predicate::eq("pager-output\n").normalize());
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[test]
 | 
					#[test]
 | 
				
			||||||
fn config_location_test() {
 | 
					fn config_location_test() {
 | 
				
			||||||
    bat_with_config()
 | 
					    bat_with_config()
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user