mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-05-13 21:26:27 +02:00
Remove vestigial color function from src/args.rs
It's usage was replaced by the `color_choice` function. Also, `color` was outdated, as it didn't include testing for the new "ansi" option.
This commit is contained in:
parent
2c98e5ce1e
commit
ff898cd105
19
src/args.rs
19
src/args.rs
@ -35,7 +35,6 @@ pub struct Args {
|
|||||||
paths: Vec<PathBuf>,
|
paths: Vec<PathBuf>,
|
||||||
after_context: usize,
|
after_context: usize,
|
||||||
before_context: usize,
|
before_context: usize,
|
||||||
color: bool,
|
|
||||||
color_choice: termcolor::ColorChoice,
|
color_choice: termcolor::ColorChoice,
|
||||||
colors: ColorSpecs,
|
colors: ColorSpecs,
|
||||||
column: bool,
|
column: bool,
|
||||||
@ -317,7 +316,6 @@ impl<'a> ArgMatches<'a> {
|
|||||||
paths: paths,
|
paths: paths,
|
||||||
after_context: after_context,
|
after_context: after_context,
|
||||||
before_context: before_context,
|
before_context: before_context,
|
||||||
color: self.color(),
|
|
||||||
color_choice: self.color_choice(),
|
color_choice: self.color_choice(),
|
||||||
colors: try!(self.color_specs()),
|
colors: try!(self.color_specs()),
|
||||||
column: self.column(),
|
column: self.column(),
|
||||||
@ -665,23 +663,6 @@ impl<'a> ArgMatches<'a> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if and only if ripgrep should color its output.
|
|
||||||
fn color(&self) -> bool {
|
|
||||||
let preference = match self.0.value_of_lossy("color") {
|
|
||||||
None => "auto".to_string(),
|
|
||||||
Some(v) => v.into_owned(),
|
|
||||||
};
|
|
||||||
if preference == "always" {
|
|
||||||
true
|
|
||||||
} else if self.is_present("vimgrep") {
|
|
||||||
false
|
|
||||||
} else if preference == "auto" {
|
|
||||||
atty::is(atty::Stream::Stdout) || self.is_present("pretty")
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the user's color choice based on command line parameters and
|
/// Returns the user's color choice based on command line parameters and
|
||||||
/// environment.
|
/// environment.
|
||||||
fn color_choice(&self) -> termcolor::ColorChoice {
|
fn color_choice(&self) -> termcolor::ColorChoice {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user