feat(cli): Add NO_COLOR support (#779)
This commit is contained in:
parent
8b39279423
commit
1846c96b86
|
@ -1,4 +1,3 @@
|
|||
-D clippy::all
|
||||
-W clippy::nursery
|
||||
-W clippy::pedantic
|
||||
-A clippy::module-name-repetitions
|
||||
|
@ -10,3 +9,4 @@
|
|||
-A clippy::default-trait-access
|
||||
-A clippy::enum-glob-use
|
||||
-A clippy::option-if-let-else
|
||||
-A clippy::blocks-in-conditions
|
||||
|
|
|
@ -680,6 +680,8 @@ pub struct Args {
|
|||
pub notify: bool,
|
||||
|
||||
/// When to use terminal colours
|
||||
///
|
||||
/// Setting the environment variable `NO_COLOR` to any value is equivalent to `--color=never`.
|
||||
#[arg(
|
||||
long,
|
||||
help_heading = OPTSET_OUTPUT,
|
||||
|
@ -1104,6 +1106,11 @@ pub fn get_args() -> Args {
|
|||
debug!("parsing arguments");
|
||||
let mut args = Args::parse_from(args);
|
||||
|
||||
// https://no-color.org/
|
||||
if args.color == ColourMode::Auto && std::env::var("NO_COLOR").is_ok() {
|
||||
args.color = ColourMode::Never;
|
||||
}
|
||||
|
||||
if args.ignore_nothing {
|
||||
args.no_global_ignore = true;
|
||||
args.no_vcs_ignore = true;
|
||||
|
|
|
@ -385,6 +385,8 @@ With this, Watchexec will emit a desktop notification when a command starts and
|
|||
.TP
|
||||
\fB\-\-color\fR=\fIMODE\fR [default: auto]
|
||||
When to use terminal colours
|
||||
|
||||
Setting the environment variable `NO_COLOR` to any value is equivalent to `\-\-color=never`.
|
||||
.TP
|
||||
\fB\-\-timings\fR
|
||||
Print how long the command took to run
|
||||
|
|
|
@ -536,6 +536,9 @@ may silently do nothing, or log a warning.
|
|||
|
||||
: When to use terminal colours
|
||||
|
||||
Setting the environment variable \`NO_COLOR\` to any value is equivalent
|
||||
to \`\--color=never\`.
|
||||
|
||||
**\--timings**
|
||||
|
||||
: Print how long the command took to run
|
||||
|
|
Loading…
Reference in New Issue