Support $NO_COLOR (#1580)

* Support `$NO_COLOR`

* run `make dev`
This commit is contained in:
John Kerl 2024-06-08 13:08:15 -04:00 committed by GitHub
parent 66abef6704
commit 8223903621
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 23 additions and 22 deletions

View file

@ -648,8 +648,8 @@ This is simply a copy of what you should see on running `man mlr` at a command p
How you can control colorization:
* Suppression/unsuppression:
* Environment variable `export MLR_NO_COLOR=true` means don't color
even if stdout+TTY.
* Environment variable `export MLR_NO_COLOR=true` or `export NO_COLOR=true`
means don't color even if stdout+TTY.
* Environment variable `export MLR_ALWAYS_COLOR=true` means do color
even if not stdout+TTY.
For example, you might want to use this when piping mlr output to `less -r`.
@ -3730,5 +3730,5 @@ This is simply a copy of what you should see on running `man mlr` at a command p
MIME Type for Comma-Separated Values (CSV) Files, the Miller docsite
https://miller.readthedocs.io
2024-05-11 4mMILLER24m(1)
2024-06-08 4mMILLER24m(1)
</pre>

View file

@ -627,8 +627,8 @@
How you can control colorization:
* Suppression/unsuppression:
* Environment variable `export MLR_NO_COLOR=true` means don't color
even if stdout+TTY.
* Environment variable `export MLR_NO_COLOR=true` or `export NO_COLOR=true`
means don't color even if stdout+TTY.
* Environment variable `export MLR_ALWAYS_COLOR=true` means do color
even if not stdout+TTY.
For example, you might want to use this when piping mlr output to `less -r`.
@ -3709,4 +3709,4 @@
MIME Type for Comma-Separated Values (CSV) Files, the Miller docsite
https://miller.readthedocs.io
2024-05-11 4mMILLER24m(1)
2024-06-08 4mMILLER24m(1)

View file

@ -50,7 +50,7 @@ described below:
* Suppression/unsuppression:
* `export MLR_NO_COLOR=true` means Miller won't color even when it normally would.
* `export MLR_NO_COLOR=true` or `export NO_COLOR=true` means Miller won't color even when it normally would.
* `export MLR_ALWAYS_COLOR=true` means Miller will color even when it normally would not. For example, you might want to use this when piping `mlr` output to `less -r`.
* Command-line flags `--no-color` or `-M`, `--always-color` or `-C`.
* On Windows, replace `export` with `set`

View file

@ -34,7 +34,7 @@ described below:
* Suppression/unsuppression:
* `export MLR_NO_COLOR=true` means Miller won't color even when it normally would.
* `export MLR_NO_COLOR=true` or `export NO_COLOR=true` means Miller won't color even when it normally would.
* `export MLR_ALWAYS_COLOR=true` means Miller will color even when it normally would not. For example, you might want to use this when piping `mlr` output to `less -r`.
* Command-line flags `--no-color` or `-M`, `--always-color` or `-C`.
* On Windows, replace `export` with `set`

View file

@ -19,6 +19,6 @@ Quick links:
The following environment variables affect how Miller works:
* `MLRRC`: see [Customization](customization.md).
* `MLR_NO_COLOR`, `MLR_ALWAYS_COLOR`, `MLR_KEY_COLOR`, `MLR_VALUE_COLOR`, `MLR_PASS_COLOR`, `MLR_FAIL_COLOR`, `MLR_REPL_PS1_COLOR`, `MLR_REPL_PS2_COLOR`, `MLR_HELP_COLOR`: see [Output Colorization](output-colorization.md).
* `MLR_NO_COLOR`, `NO_COLOR`, `MLR_ALWAYS_COLOR`, `MLR_KEY_COLOR`, `MLR_VALUE_COLOR`, `MLR_PASS_COLOR`, `MLR_FAIL_COLOR`, `MLR_REPL_PS1_COLOR`, `MLR_REPL_PS2_COLOR`, `MLR_HELP_COLOR`: see [Output Colorization](output-colorization.md).
* `MLR_REPL_PS1`, `MLR_REPL_PS2`: see [REPL](repl.md).

View file

@ -3,6 +3,6 @@
The following environment variables affect how Miller works:
* `MLRRC`: see [Customization](customization.md).
* `MLR_NO_COLOR`, `MLR_ALWAYS_COLOR`, `MLR_KEY_COLOR`, `MLR_VALUE_COLOR`, `MLR_PASS_COLOR`, `MLR_FAIL_COLOR`, `MLR_REPL_PS1_COLOR`, `MLR_REPL_PS2_COLOR`, `MLR_HELP_COLOR`: see [Output Colorization](output-colorization.md).
* `MLR_NO_COLOR`, `NO_COLOR`, `MLR_ALWAYS_COLOR`, `MLR_KEY_COLOR`, `MLR_VALUE_COLOR`, `MLR_PASS_COLOR`, `MLR_FAIL_COLOR`, `MLR_REPL_PS1_COLOR`, `MLR_REPL_PS2_COLOR`, `MLR_HELP_COLOR`: see [Output Colorization](output-colorization.md).
* `MLR_REPL_PS1`, `MLR_REPL_PS2`: see [REPL](repl.md).

View file

@ -328,8 +328,8 @@ Mechanisms for coloring:
How you can control colorization:
* Suppression/unsuppression:
* Environment variable `export MLR_NO_COLOR=true` means don't color
even if stdout+TTY.
* Environment variable `export MLR_NO_COLOR=true` or `export NO_COLOR=true`
means don't color even if stdout+TTY.
* Environment variable `export MLR_ALWAYS_COLOR=true` means do color
even if not stdout+TTY.
For example, you might want to use this when piping mlr output to `less -r`.

View file

@ -627,8 +627,8 @@
How you can control colorization:
* Suppression/unsuppression:
* Environment variable `export MLR_NO_COLOR=true` means don't color
even if stdout+TTY.
* Environment variable `export MLR_NO_COLOR=true` or `export NO_COLOR=true`
means don't color even if stdout+TTY.
* Environment variable `export MLR_ALWAYS_COLOR=true` means do color
even if not stdout+TTY.
For example, you might want to use this when piping mlr output to `less -r`.
@ -3709,4 +3709,4 @@
MIME Type for Comma-Separated Values (CSV) Files, the Miller docsite
https://miller.readthedocs.io
2024-05-11 4mMILLER24m(1)
2024-06-08 4mMILLER24m(1)

View file

@ -2,12 +2,12 @@
.\" Title: mlr
.\" Author: [see the "AUTHOR" section]
.\" Generator: ./mkman.rb
.\" Date: 2024-05-11
.\" Date: 2024-06-08
.\" Manual: \ \&
.\" Source: \ \&
.\" Language: English
.\"
.TH "MILLER" "1" "2024-05-11" "\ \&" "\ \&"
.TH "MILLER" "1" "2024-06-08" "\ \&" "\ \&"
.\" -----------------------------------------------------------------
.\" * Portability definitions
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -756,8 +756,8 @@ Mechanisms for coloring:
How you can control colorization:
* Suppression/unsuppression:
* Environment variable `export MLR_NO_COLOR=true` means don't color
even if stdout+TTY.
* Environment variable `export MLR_NO_COLOR=true` or `export NO_COLOR=true`
means don't color even if stdout+TTY.
* Environment variable `export MLR_ALWAYS_COLOR=true` means do color
even if not stdout+TTY.
For example, you might want to use this when piping mlr output to `less -r`.

View file

@ -2715,8 +2715,8 @@ Mechanisms for coloring:
How you can control colorization:
* Suppression/unsuppression:
* Environment variable ` + "`export MLR_NO_COLOR=true`" + ` means don't color
even if stdout+TTY.
* Environment variable ` + "`export MLR_NO_COLOR=true` or `export NO_COLOR=true`" + `
means don't color even if stdout+TTY.
* Environment variable ` + "`export MLR_ALWAYS_COLOR=true`" + ` means do color
even if not stdout+TTY.
For example, you might want to use this when piping mlr output to ` + "`less -r`" + `.

View file

@ -198,7 +198,8 @@ var stdoutIsATTY = getStdoutIsATTY()
// Read environment variables at startup time. These can be overridden
// afterward using command-line flags.
func init() {
if os.Getenv("MLR_NO_COLOR") != "" {
if os.Getenv("MLR_NO_COLOR") != "" || os.Getenv("NO_COLOR") != "" {
colorization = ColorizeOutputNever
colorization = ColorizeOutputNever
} else if os.Getenv("MLR_ALWAYS_COLOR") != "" {
colorization = ColorizeOutputAlways