Skip to content

Commit

Permalink
Add -pp for plain styling and no pager
Browse files Browse the repository at this point in the history
  • Loading branch information
eth-p authored and sharkdp committed May 10, 2019
1 parent bb6594e commit fde00ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,10 @@ impl App {
Some("always") => PagingMode::Always,
Some("never") => PagingMode::Never,
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
// interactive terminal and if we do not *read* from an interactive
// terminal.
Expand Down
5 changes: 3 additions & 2 deletions src/clap_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,11 @@ pub fn build_app(interactive_output: bool) -> ClapApp<'static, 'static> {
.overrides_with("number")
.short("p")
.long("plain")
.multiple(true)
.help("Show plain style (alias for '--style=plain').")
.long_help(
"Only show plain style, no decorations. This is an alias for \
'--style=plain'",
"Only show plain style, no decorations. When '-p' is used, this is an alias for \
'--style=plain'. When '-pp' is used, this is an alias for '--style=plain --pager=never'.",
),
)
.arg(
Expand Down

0 comments on commit fde00ee

Please sign in to comment.