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") { let paging_mode = match self.matches.value_of("paging") {
Some("always") => PagingMode::Always, Some("always") => PagingMode::Always,
Some("never") => PagingMode::Never, Some("never") => PagingMode::Never,
Some("auto") | _ => if files.contains(&InputFile::StdIn) { Some("auto") | _ => {
// If we are reading from stdin, only enable paging if we write to an if files.contains(&InputFile::StdIn) {
// interactive terminal and if we do not *read* from an interactive // If we are reading from stdin, only enable paging if we write to an
// terminal. // interactive terminal and if we do not *read* from an interactive
if self.interactive_output && !atty::is(Stream::Stdin) { // terminal.
PagingMode::QuitIfOneScreen if self.interactive_output && !atty::is(Stream::Stdin) {
PagingMode::QuitIfOneScreen
} else {
PagingMode::Never
}
} else { } else {
PagingMode::Never if self.interactive_output {
PagingMode::QuitIfOneScreen
} else {
PagingMode::Never
}
} }
} else { }
if self.interactive_output {
PagingMode::QuitIfOneScreen
} else {
PagingMode::Never
}
},
}; };
Ok(Config { Ok(Config {
@ -393,11 +395,13 @@ impl App {
match self.matches.value_of("wrap") { match self.matches.value_of("wrap") {
Some("character") => OutputWrap::Character, Some("character") => OutputWrap::Character,
Some("never") => OutputWrap::None, Some("never") => OutputWrap::None,
Some("auto") | _ => if output_components.plain() { Some("auto") | _ => {
OutputWrap::None if output_components.plain() {
} else { OutputWrap::None
OutputWrap::Character } else {
}, OutputWrap::Character
}
}
} }
}, },
colored_output: match self.matches.value_of("color") { colored_output: match self.matches.value_of("color") {
@ -450,8 +454,10 @@ impl App {
} else { } else {
InputFile::Ordinary(filename) InputFile::Ordinary(filename)
} }
}).collect() })
}).unwrap_or_else(|| vec![InputFile::StdIn]) .collect()
})
.unwrap_or_else(|| vec![InputFile::StdIn])
} }
fn output_components(&self) -> Result<OutputComponents> { fn output_components(&self) -> Result<OutputComponents> {

View File

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

View File

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

View File

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