From adc3410395771609d2db5ee5ae2b9da71115c5ca Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Mon, 14 Sep 2026 11:05:13 +0200 Subject: 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. --- cmd/krino/history_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'cmd/krino/history_test.go') diff --git a/cmd/krino/history_test.go b/cmd/krino/history_test.go index 23b1e5f..f76ac66 100644 --- a/cmd/krino/history_test.go +++ b/cmd/krino/history_test.go @@ -150,7 +150,7 @@ func TestFinalizeUndoPlanMarksUnapprovedAsDeclined(t *testing.T) { // TestReviewUndoApplyAll: [a] approves every reversible file by index. func TestReviewUndoApplyAll(t *testing.T) { - approved, action, err := reviewUndoFiles(strings.NewReader("a"), new(strings.Builder), undoFiles("a", "b")) + approved, action, err := reviewUndoFiles(strings.NewReader("a"), new(strings.Builder), undoFiles("a", "b"), palette{}) if err != nil { t.Fatal(err) } @@ -161,11 +161,11 @@ func TestReviewUndoApplyAll(t *testing.T) { // TestReviewUndoSkipAndQuit: [s] and [q] both approve nothing. func TestReviewUndoSkipAndQuit(t *testing.T) { - approved, action, _ := reviewUndoFiles(strings.NewReader("s"), new(strings.Builder), undoFiles("a", "b")) + approved, action, _ := reviewUndoFiles(strings.NewReader("s"), new(strings.Builder), undoFiles("a", "b"), palette{}) if action != 's' || len(approved) != 0 { t.Errorf("[s] = %q %v; want nothing approved", action, approved) } - approved, action, _ = reviewUndoFiles(strings.NewReader("q"), new(strings.Builder), undoFiles("a", "b")) + approved, action, _ = reviewUndoFiles(strings.NewReader("q"), new(strings.Builder), undoFiles("a", "b"), palette{}) if action != 'q' || len(approved) != 0 { t.Errorf("[q] = %q %v; want nothing approved", action, approved) } @@ -173,7 +173,7 @@ func TestReviewUndoSkipAndQuit(t *testing.T) { // TestReviewUndoChoosePerFile: [c] then per-file y/n, keyed by index. func TestReviewUndoChoosePerFile(t *testing.T) { - approved, action, err := reviewUndoFiles(strings.NewReader("cyn"), new(strings.Builder), undoFiles("a", "b")) + approved, action, err := reviewUndoFiles(strings.NewReader("cyn"), new(strings.Builder), undoFiles("a", "b"), palette{}) if err != nil { t.Fatal(err) } @@ -195,7 +195,7 @@ func TestReviewUndoRefusedFileNotPrompted(t *testing.T) { files := undoFiles("a", "b", "c") files[1].Refused = "b changed since the run" out := new(strings.Builder) - approved, action, err := reviewUndoFiles(strings.NewReader("cyn"), out, files) + approved, action, err := reviewUndoFiles(strings.NewReader("cyn"), out, files, palette{}) if err != nil { t.Fatal(err) } @@ -304,7 +304,7 @@ func TestPrintUndoPlan(t *testing.T) { // TestInvalidKeyReprompts for the undo-specific menu. func TestReviewUndoInvalidKeyReprompts(t *testing.T) { out := new(strings.Builder) - approved, action, err := reviewUndoFiles(strings.NewReader("zs"), out, undoFiles("a")) + approved, action, err := reviewUndoFiles(strings.NewReader("zs"), out, undoFiles("a"), palette{}) if err != nil { t.Fatal(err) } -- cgit v1.3