mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-07 13:41:14 +00:00
fix some clippy warnings
This commit is contained in:
parent
51463a4b41
commit
43b2ee5e71
@ -169,9 +169,7 @@ impl App {
|
|||||||
|| match self.matches.value_of("color") {
|
|| match self.matches.value_of("color") {
|
||||||
Some("always") => true,
|
Some("always") => true,
|
||||||
Some("never") => false,
|
Some("never") => false,
|
||||||
Some("auto") | _ => {
|
_ => env::var_os("NO_COLOR").is_none() && self.interactive_output,
|
||||||
env::var_os("NO_COLOR").is_none() && self.interactive_output
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
paging_mode,
|
paging_mode,
|
||||||
term_width: maybe_term_width.unwrap_or(Term::stdout().size().1 as usize),
|
term_width: maybe_term_width.unwrap_or(Term::stdout().size().1 as usize),
|
||||||
@ -226,17 +224,14 @@ impl App {
|
|||||||
style_components,
|
style_components,
|
||||||
syntax_mapping,
|
syntax_mapping,
|
||||||
pager: self.matches.value_of("pager"),
|
pager: self.matches.value_of("pager"),
|
||||||
use_italic_text: match self.matches.value_of("italic-text") {
|
use_italic_text: matches!(self.matches.value_of("italic-text"), Some("always")),
|
||||||
Some("always") => true,
|
|
||||||
_ => false,
|
|
||||||
},
|
|
||||||
highlighted_lines: self
|
highlighted_lines: self
|
||||||
.matches
|
.matches
|
||||||
.values_of("highlight-line")
|
.values_of("highlight-line")
|
||||||
.map(|ws| ws.map(LineRange::from).collect())
|
.map(|ws| ws.map(LineRange::from).collect())
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.map(LineRanges::from)
|
.map(LineRanges::from)
|
||||||
.map(|lr| HighlightedLineRanges(lr))
|
.map(HighlightedLineRanges)
|
||||||
.unwrap_or_default(),
|
.unwrap_or_default(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ pub fn get_args_from_config_file() -> Result<Vec<OsString>, shell_words::ParseEr
|
|||||||
.ok()
|
.ok()
|
||||||
.map(|content| get_args_from_str(&content))
|
.map(|content| get_args_from_str(&content))
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.unwrap_or_else(|| vec![]))
|
.unwrap_or_else(Vec::new))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_args_from_env_var() -> Option<Result<Vec<OsString>, shell_words::ParseError>> {
|
pub fn get_args_from_env_var() -> Option<Result<Vec<OsString>, shell_words::ParseError>> {
|
||||||
|
@ -161,7 +161,7 @@ impl<'b> Controller<'b> {
|
|||||||
Ok(no_errors)
|
Ok(no_errors)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_file<'a>(
|
fn print_file(
|
||||||
&self,
|
&self,
|
||||||
printer: &mut dyn Printer,
|
printer: &mut dyn Printer,
|
||||||
writer: &mut dyn Write,
|
writer: &mut dyn Write,
|
||||||
|
11
src/input.rs
11
src/input.rs
@ -137,17 +137,12 @@ impl<'a> Input<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_stdin(&self) -> bool {
|
pub fn is_stdin(&self) -> bool {
|
||||||
if let InputKind::StdIn = self.kind {
|
matches!(self.kind, InputKind::StdIn)
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_name(mut self, provided_name: Option<&OsStr>) -> Self {
|
pub fn with_name(mut self, provided_name: Option<&OsStr>) -> Self {
|
||||||
match provided_name {
|
if let Some(name) = provided_name {
|
||||||
Some(name) => self.description.name = name.to_string_lossy().to_string(),
|
self.description.name = name.to_string_lossy().to_string()
|
||||||
None => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.metadata.user_provided_name = provided_name.map(|n| n.to_owned());
|
self.metadata.user_provided_name = provided_name.map(|n| n.to_owned());
|
||||||
|
@ -150,11 +150,7 @@ impl OutputType {
|
|||||||
|
|
||||||
#[cfg(feature = "paging")]
|
#[cfg(feature = "paging")]
|
||||||
pub(crate) fn is_pager(&self) -> bool {
|
pub(crate) fn is_pager(&self) -> bool {
|
||||||
if let OutputType::Pager(_) = self {
|
matches!(self, OutputType::Pager(_))
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "paging"))]
|
#[cfg(not(feature = "paging"))]
|
||||||
|
@ -338,7 +338,7 @@ impl<'a> Input<'a> {
|
|||||||
|
|
||||||
/// A new input from bytes.
|
/// A new input from bytes.
|
||||||
pub fn from_bytes(bytes: &'a [u8]) -> Self {
|
pub fn from_bytes(bytes: &'a [u8]) -> Self {
|
||||||
Input::from_reader(bytes).into()
|
Input::from_reader(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A new input from STDIN.
|
/// A new input from STDIN.
|
||||||
|
@ -311,7 +311,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
|||||||
description
|
description
|
||||||
.kind()
|
.kind()
|
||||||
.map(|kind| format!("{}: ", kind))
|
.map(|kind| format!("{}: ", kind))
|
||||||
.unwrap_or("".into()),
|
.unwrap_or_else(|| "".into()),
|
||||||
self.colors.filename.paint(description.title()),
|
self.colors.filename.paint(description.title()),
|
||||||
mode
|
mode
|
||||||
)?;
|
)?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user