mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
New flag: --no-colors (disables colored output) (#2507)
Co-authored-by: Jeffrey Cafferata <jeffrey@jcid.nl> Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
@@ -12,6 +12,8 @@ import (
|
|||||||
"github.com/StackExchange/dnscontrol/v4/pkg/js"
|
"github.com/StackExchange/dnscontrol/v4/pkg/js"
|
||||||
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
|
"github.com/StackExchange/dnscontrol/v4/pkg/printer"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
|
"github.com/fatih/color"
|
||||||
)
|
)
|
||||||
|
|
||||||
// categories of commands
|
// categories of commands
|
||||||
@@ -68,6 +70,12 @@ func Run(v string) int {
|
|||||||
Destination: &diff2.EnableDiff2,
|
Destination: &diff2.EnableDiff2,
|
||||||
Value: true,
|
Value: true,
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "no-colors",
|
||||||
|
Usage: "Disable colors",
|
||||||
|
Destination: &color.NoColor,
|
||||||
|
Value: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
sort.Sort(cli.CommandsByName(commands))
|
sort.Sort(cli.CommandsByName(commands))
|
||||||
app.Commands = commands
|
app.Commands = commands
|
||||||
|
@@ -8,6 +8,7 @@
|
|||||||
* [Examples](examples.md)
|
* [Examples](examples.md)
|
||||||
* [Migrating zones to DNSControl](migrating.md)
|
* [Migrating zones to DNSControl](migrating.md)
|
||||||
* [TypeScript autocomplete and type checking](typescript.md)
|
* [TypeScript autocomplete and type checking](typescript.md)
|
||||||
|
* [Disabling Colors](colors.md)
|
||||||
|
|
||||||
## Language Reference
|
## Language Reference
|
||||||
|
|
||||||
|
27
documentation/colors.md
Normal file
27
documentation/colors.md
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Colors support
|
||||||
|
|
||||||
|
DNSControl is using colors on both its console and notification outputs, to
|
||||||
|
denote changes, such as during preview or push events.
|
||||||
|
|
||||||
|
This is on by default in all interactive prompts supporting colors. See below on
|
||||||
|
how to bypass it.
|
||||||
|
|
||||||
|
## Disable colors
|
||||||
|
|
||||||
|
There are cases that we might need to disable colored output, such as in certain
|
||||||
|
CI environments or particular notification mechanisms that don't support ANSI color
|
||||||
|
codes.
|
||||||
|
|
||||||
|
In order to do so, a global `--no-colors` command option is provided, which when
|
||||||
|
set `--no-colors=true`, will disable colors globally.
|
||||||
|
|
||||||
|
## (Force) Enable colors
|
||||||
|
|
||||||
|
If color support is not correctly detected, providing `--no-colors=false` would
|
||||||
|
force-enable coloring, bypassing modules TTY detection.
|
||||||
|
|
||||||
|
## Force colors in CI environments
|
||||||
|
|
||||||
|
Some CI environments, while supporting colors, fail autodetection, such as GHA.
|
||||||
|
In that case, colors can be forcibly enabled via `--no-colors=false` or by setting
|
||||||
|
a `CI` env variable to `true` (if not autoset).
|
Reference in New Issue
Block a user