Skip to content

Commit

Permalink
Wrapping disabled when --plain is used. (#289)
Browse files Browse the repository at this point in the history
  • Loading branch information
eth-p authored and sharkdp committed Sep 8, 2018
1 parent 76df41f commit fb61aa4
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,11 @@ impl App {
.long("plain")
.conflicts_with("style")
.conflicts_with("number")
.help("Show plain style (alias for '--style=plain').")
.conflicts_with("wrap")
.help("Show plain style (alias for '--style=plain' and '--wrap=never').")
.long_help(
"Only show plain style, no decorations. This is an alias for \
'--style=plain'",
"Only show plain style, no decorations, no wrapping. This is an alias for \
'--style=plain' and '--wrap=never'",
),
).arg(
Arg::with_name("number")
Expand Down Expand Up @@ -348,6 +349,9 @@ impl App {
// We don't have the tty width when piping to another program.
// There's no point in wrapping when this is the case.
OutputWrap::None
} else if self.matches.is_present("plain") {
// No point in wrapping when it's plain.
OutputWrap::None
} else {
match self.matches.value_of("wrap") {
Some("character") => OutputWrap::Character,
Expand Down Expand Up @@ -379,17 +383,15 @@ impl App {
}
},
},
term_width: self
.matches
term_width: self.matches
.value_of("terminal-width")
.and_then(|w| w.parse().ok())
.unwrap_or(Term::stdout().size().1 as usize),
loop_through: !(self.interactive_output
|| self.matches.value_of("color") == Some("always")
|| self.matches.value_of("decorations") == Some("always")),
files,
theme: self
.matches
theme: self.matches
.value_of("theme")
.map(String::from)
.or_else(|| env::var("BAT_THEME").ok())
Expand All @@ -409,8 +411,10 @@ impl App {
} else {
InputFile::Ordinary(filename)
}
}).collect()
}).unwrap_or_else(|| vec![InputFile::StdIn])
})
.collect()
})
.unwrap_or_else(|| vec![InputFile::StdIn])
}

fn output_components(&self) -> Result<OutputComponents> {
Expand Down

0 comments on commit fb61aa4

Please sign in to comment.