diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 11:05:13 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 11:05:13 +0200 |
| commit | adc3410395771609d2db5ee5ae2b9da71115c5ca (patch) | |
| tree | 453def41e18f607332be1088920f9d0c563603a3 /cmd/krino/main.go | |
| parent | 0468ce38470aa3ae8092b92d4f77e72d25dfa108 (diff) | |
| download | krino-adc3410395771609d2db5ee5ae2b9da71115c5ca.tar.gz krino-adc3410395771609d2db5ee5ae2b9da71115c5ca.zip | |
krino: coloured output, and --no-color
One palette type styles the plan table, warnings, headers, outcome counts,
prompt keys, undo's refused steps and krino log's (undone), from the
16-colour ANSI palette plus bold and faint only. Widths are measured on the
plain text, so columns line up; with colour off the output is unchanged.
--no-color works before or after any subcommand, as NO_COLOR does. The two
search-and-replace colourings are gone.
Diffstat (limited to 'cmd/krino/main.go')
| -rw-r--r-- | cmd/krino/main.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/cmd/krino/main.go b/cmd/krino/main.go index f5fdfea..12fdf5f 100644 --- a/cmd/krino/main.go +++ b/cmd/krino/main.go @@ -50,6 +50,7 @@ Sort the files in the directories listed in krino.conf by their rules. -v also list unmatched, ignored and busy files --json with -n: print the plan as JSON -c FILE use FILE instead of ~/.config/krino/krino.conf + --no-color never colour the output, as when NO_COLOR is set -h, --help show this help --version print the version ` @@ -57,6 +58,7 @@ Sort the files in the directories listed in krino.conf by their rules. // globals holds the flags that may appear before or after a subcommand. type globals struct { yes, dry, verbose, json bool + noColor bool conf string } @@ -108,11 +110,14 @@ func run(args []string, stdout, stderr io.Writer) int { return cmdSort(g, rest, stdout, stderr) } -// flagSet returns a silent flag set with -c bound to g, shared by every command. +// flagSet returns a silent flag set with -c and --no-color bound to g, +// shared by every command. Each defaults to the value already parsed, so a +// flag given before a subcommand survives the subcommand's own flag set. func flagSet(name string, g *globals) *flag.FlagSet { fs := flag.NewFlagSet(name, flag.ContinueOnError) fs.SetOutput(io.Discard) fs.StringVar(&g.conf, "c", g.conf, "") + fs.BoolVar(&g.noColor, "no-color", g.noColor, "") return fs } |
