run cargo fmt

This commit is contained in:
sharkdp 2018-09-26 19:16:03 +02:00
parent 64903bb858
commit 80da0dc619
4 changed files with 38 additions and 28 deletions

View File

@ -364,22 +364,24 @@ impl App {
let paging_mode = match self.matches.value_of("paging") {
Some("always") => PagingMode::Always,
Some("never") => PagingMode::Never,
Some("auto") | _ => 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.
if self.interactive_output && !atty::is(Stream::Stdin) {
PagingMode::QuitIfOneScreen
Some("auto") | _ => {
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.
if self.interactive_output && !atty::is(Stream::Stdin) {
PagingMode::QuitIfOneScreen
} else {
PagingMode::Never
}
} else {
PagingMode::Never
if self.interactive_output {
PagingMode::QuitIfOneScreen
} else {
PagingMode::Never
}
}
} else {
if self.interactive_output {
PagingMode::QuitIfOneScreen
} else {
PagingMode::Never
}
},
}
};
Ok(Config {
@ -393,11 +395,13 @@ impl App {
match self.matches.value_of("wrap") {
Some("character") => OutputWrap::Character,
Some("never") => OutputWrap::None,
Some("auto") | _ => if output_components.plain() {
OutputWrap::None
} else {
OutputWrap::Character
},
Some("auto") | _ => {
if output_components.plain() {
OutputWrap::None
} else {
OutputWrap::Character
}
}
}
},
colored_output: match self.matches.value_of("color") {
@ -450,8 +454,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> {

View File

@ -319,7 +319,8 @@ impl<'a> Printer for InteractivePrinter<'a> {
.iter()
.map(|ref d| d
.generate(line_number, true, self)
.text).collect::<Vec<String>>()
.text)
.collect::<Vec<String>>()
.join(" ")
))
} else {

View File

@ -23,11 +23,13 @@ pub enum OutputWrap {
impl OutputComponent {
pub fn components(&self, interactive_terminal: bool) -> &'static [OutputComponent] {
match *self {
OutputComponent::Auto => if interactive_terminal {
OutputComponent::Full.components(interactive_terminal)
} else {
OutputComponent::Plain.components(interactive_terminal)
},
OutputComponent::Auto => {
if interactive_terminal {
OutputComponent::Full.components(interactive_terminal)
} else {
OutputComponent::Plain.components(interactive_terminal)
}
}
OutputComponent::Changes => &[OutputComponent::Changes],
OutputComponent::Grid => &[OutputComponent::Grid],
OutputComponent::Header => &[OutputComponent::Header],

View File

@ -50,7 +50,8 @@ impl BatTester {
&format!("--wrap={}", if wrap { "character" } else { "never" }),
&format!("--tabs={}", tab_width),
&format!("--style={}", style),
]).output()
])
.output()
.expect("bat failed");
// have to do the replace because the filename in the header changes based on the current working directory