diff --git a/src/app.rs b/src/app.rs index 3217467..e43dc5a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -80,7 +80,8 @@ pub fn app() -> App<'static, 'static> { .value_name("WHEN") .takes_value(true) .hide_possible_values(true) - .possible_values(&["never", "auto", "always", "ansi"])) + .possible_values(&["never", "auto", "always", "ansi"]) + .default_value_if("vimgrep", None, "never")) .arg(flag("colors").value_name("SPEC") .takes_value(true).multiple(true).number_of_values(1)) .arg(flag("encoding").short("E").value_name("ENCODING") @@ -91,7 +92,7 @@ pub fn app() -> App<'static, 'static> { .value_name("GLOB")) .arg(flag("ignore-case").short("i")) .arg(flag("line-number").short("n")) - .arg(flag("no-line-number").short("N")) + .arg(flag("no-line-number").short("N").overrides_with("line-number")) .arg(flag("quiet").short("q")) .arg(flag("type").short("t") .takes_value(true).multiple(true).number_of_values(1) @@ -125,8 +126,8 @@ pub fn app() -> App<'static, 'static> { .arg(flag("files-with-matches").short("l")) .arg(flag("files-without-match")) .arg(flag("with-filename").short("H")) - .arg(flag("no-filename")) - .arg(flag("heading").overrides_with("no-heading")) + .arg(flag("no-filename").overrides_with("with-filename")) + .arg(flag("heading")) .arg(flag("no-heading").overrides_with("heading")) .arg(flag("hidden")) .arg(flag("ignore-file") @@ -160,7 +161,7 @@ pub fn app() -> App<'static, 'static> { .arg(flag("threads") .short("j").value_name("ARG").takes_value(true) .validator(validate_number)) - .arg(flag("vimgrep")) + .arg(flag("vimgrep").overrides_with("count")) .arg(flag("max-columns").short("M") .value_name("NUM").takes_value(true) .validator(validate_number)) diff --git a/src/args.rs b/src/args.rs index b6f0138..068a40d 100644 --- a/src/args.rs +++ b/src/args.rs @@ -589,9 +589,9 @@ impl<'a> ArgMatches<'a> { false } else { let only_stdin = paths == &[Path::new("-")]; - self.is_present("line-number") + (atty::is(atty::Stream::Stdout) && !only_stdin) + || self.is_present("line-number") || self.is_present("column") - || (atty::is(atty::Stream::Stdout) && !only_stdin) || self.is_present("pretty") || self.is_present("vimgrep") } @@ -605,11 +605,11 @@ impl<'a> ArgMatches<'a> { /// Returns true if and only if matches should be grouped with file name /// headings. fn heading(&self) -> bool { - if self.is_present("no-heading") { + if self.is_present("no-heading") || self.is_present("vimgrep") { false } else { - self.is_present("heading") - || atty::is(atty::Stream::Stdout) + atty::is(atty::Stream::Stdout) + || self.is_present("heading") || self.is_present("pretty") } } @@ -674,8 +674,6 @@ impl<'a> ArgMatches<'a> { termcolor::ColorChoice::Always } else if preference == "ansi" { termcolor::ColorChoice::AlwaysAnsi - } else if self.is_present("vimgrep") { - termcolor::ColorChoice::Never } else if preference == "auto" { if atty::is(atty::Stream::Stdout) || self.is_present("pretty") { termcolor::ColorChoice::Auto