on master help sign in
Wrapping disabled when --plain is used. (#289)
commitfb61aa4f60096eebd59b48367465cd88279d3180 authoreth-p <32112321+eth-p@users.noreply.github.com> dateFri 7 Sep 2018, 10:27 (8 years ago) parent76df41f
1 file changed+13−9
src/app.rs+13−9
src/app.rs+13−9
@@ -190,10 +190,11 @@ impl App {
190190 .long("plain")
191191 .conflicts_with("style")
192192 .conflicts_with("number")
193− .help("Show plain style (alias for '--style=plain').")
193+ .conflicts_with("wrap")
194+ .help("Show plain style (alias for '--style=plain' and '--wrap=never').")
194195 .long_help(
195− "Only show plain style, no decorations. This is an alias for \
196− '--style=plain'",
196+ "Only show plain style, no decorations, no wrapping. This is an alias for \
197+ '--style=plain' and '--wrap=never'",
197198 ),
198199 ).arg(
199200 Arg::with_name("number")
@@ -348,6 +349,9 @@ impl App {
348349 // We don't have the tty width when piping to another program.
349350 // There's no point in wrapping when this is the case.
350351 OutputWrap::None
352+ } else if self.matches.is_present("plain") {
353+ // No point in wrapping when it's plain.
354+ OutputWrap::None
351355 } else {
352356 match self.matches.value_of("wrap") {
353357 Some("character") => OutputWrap::Character,
@@ -379,8 +383,7 @@ impl App {
379383 }
380384 },
381385 },
382− term_width: self
383− .matches
386+ term_width: self.matches
384387 .value_of("terminal-width")
385388 .and_then(|w| w.parse().ok())
386389 .unwrap_or(Term::stdout().size().1 as usize),
@@ -388,8 +391,7 @@ impl App {
388391 || self.matches.value_of("color") == Some("always")
389392 || self.matches.value_of("decorations") == Some("always")),
390393 files,
391− theme: self
392− .matches
394+ theme: self.matches
393395 .value_of("theme")
394396 .map(String::from)
395397 .or_else(|| env::var("BAT_THEME").ok())
@@ -409,8 +411,10 @@ impl App {
409411 } else {
410412 InputFile::Ordinary(filename)
411413 }
412− }).collect()
413− }).unwrap_or_else(|| vec![InputFile::StdIn])
414+ })
415+ .collect()
416+ })
417+ .unwrap_or_else(|| vec![InputFile::StdIn])
414418 }
415419
416420 fn output_components(&self) -> Result<OutputComponents> {