Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support $NO_COLOR #1580

Merged
merged 2 commits into from
Jun 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/src/manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,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`.
Expand Down Expand Up @@ -1077,7 +1077,7 @@

1mfilter0m
Usage: mlr filter [options] {DSL expression}
Lets you use a domain-specific language to progamatically filter which

Check failure on line 1080 in docs/src/manpage.md

View workflow job for this annotation

GitHub Actions / Codespell

progamatically ==> programmatically
stream records will be output.
See also: https://miller.readthedocs.io/en/latest/reference-verbs

Expand Down Expand Up @@ -1535,7 +1535,7 @@

1mput0m
Usage: mlr put [options] {DSL expression}
Lets you use a domain-specific language to progamatically alter stream records.

Check failure on line 1538 in docs/src/manpage.md

View workflow job for this annotation

GitHub Actions / Codespell

progamatically ==> programmatically
See also: https://miller.readthedocs.io/en/latest/reference-verbs

Options:
Expand Down Expand Up @@ -3730,5 +3730,5 @@
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>
6 changes: 3 additions & 3 deletions docs/src/manpage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion docs/src/output-colorization.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion docs/src/output-colorization.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion docs/src/reference-main-env-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

2 changes: 1 addition & 1 deletion docs/src/reference-main-env-vars.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -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).

4 changes: 2 additions & 2 deletions docs/src/reference-main-flag-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
6 changes: 3 additions & 3 deletions man/manpage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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)
8 changes: 4 additions & 4 deletions man/mlr.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions pkg/cli/option_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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`" + `.
Expand Down
3 changes: 2 additions & 1 deletion pkg/colorizer/colorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading