Skip to content
Myr

Add flag to force color

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Color can now be forced on even when piping the output. Changed the --no-color flag to --color which uses the same options that ripgrep uses for --color (excluding ansi). Closes #49.

authored by Antti Keränen · committed by David Peter · parent 2256aff · Browse files · 1 file+11 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+11 added−6 removed

  • other:+11 added−6 removed

1 file+11 added−6 removed

modified:src/main.rs+11 added-6 removed
387 unmodified lines
388 .arg(Arg::with_name("absolute-path")389 .long("absolute-path")390 .short("a")391 .help("Show absolute instead of relative paths"))392 .arg(Arg::with_name("no-color")393 .long("no-color")394 .short("n")395 .help("Do not colorize output"))392 .arg(Arg::with_name("color")393 .long("color")394 .short("c")395 .takes_value(true)396 .possible_values(&["never", "auto", "always"])397 .help("When to use color in the output. The default is auto."))398 .arg(Arg::with_name("depth")399 .long("max-depth")400 .short("d")401 .takes_value(true)
60 unmodified lines
462 // if the pattern has an uppercase character (smart case).463 let case_sensitive = matches.is_present("case-sensitive") ||464 pattern.chars().any(char::is_uppercase);465464 let colored_output = !matches.is_present("no-color") &&465 atty::is(Stream::Stdout);466 let colored_output = match matches.value_of("color") {467 Some("always") => true,468 Some("never") => false,469 _ => atty::is(Stream::Stdout)470 };471472 let ls_colors =473 if colored_output {474 Some(
56 unmodified lines