Add -pp for plain styling and no pager

This commit is contained in:
Ethan P 2019-05-08 18:56:02 -07:00 committed by David Peter
parent bb6594e691
commit fde00eec98
2 changed files with 7 additions and 3 deletions

View file

@ -143,7 +143,10 @@ impl App {
Some("always") => PagingMode::Always, Some("always") => PagingMode::Always,
Some("never") => PagingMode::Never, Some("never") => PagingMode::Never,
Some("auto") | _ => { Some("auto") | _ => {
if files.contains(&InputFile::StdIn) { if self.matches.occurrences_of("plain") > 1 {
// If we have -pp as an option when in auto mode, the pager should be disabled.
PagingMode::Never
} else if files.contains(&InputFile::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
// terminal. // terminal.

View file

@ -143,10 +143,11 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.overrides_with("number") .overrides_with("number")
.short("p") .short("p")
.long("plain") .long("plain")
.multiple(true)
.help("Show plain style (alias for '--style=plain').") .help("Show plain style (alias for '--style=plain').")
.long_help( .long_help(
"Only show plain style, no decorations. This is an alias for \ "Only show plain style, no decorations. When '-p' is used, this is an alias for \
'--style=plain'", '--style=plain'. When '-pp' is used, this is an alias for '--style=plain --pager=never'.",
), ),
) )
.arg( .arg(