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/log.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/log.go')
| -rw-r--r-- | cmd/krino/log.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/cmd/krino/log.go b/cmd/krino/log.go index 6eb15d6..bcbe1d0 100644 --- a/cmd/krino/log.go +++ b/cmd/krino/log.go @@ -86,12 +86,23 @@ func cmdLog(g *globals, args []string, stdout, stderr io.Writer) int { return 0 } + p := palette{on: colourOn(g, stdout)} for _, r := range runs { - fmt.Fprintln(stdout, formatRun(r)) + fmt.Fprintln(stdout, styleUndone(formatRun(r), p)) } return 0 } +// styleUndone styles the "(undone)" formatRun appends, faint (spec ยง8.2); +// a line without it is returned as is. +func styleUndone(line string, p palette) string { + const mark = " (undone)" + if !p.on || !strings.HasSuffix(line, mark) { + return line + } + return strings.TrimSuffix(line, mark) + " " + p.faint("(undone)") +} + // formatRun renders one journal.Run as krino log lists it: id, start time, // the directories it touched, and its counts (see countsText), with // "(undone)" appended when a later run has reversed it. |
