From c7312ae81236f00cf19c161a6a2aa0e4bcfc12e1 Mon Sep 17 00:00:00 2001 From: Michael Aguiar Date: Sat, 5 Dec 2026 11:05:06 -0700 Subject: [PATCH] Say "1 entry" in the notch report text output (ALI-2672) The hours and unbilled lines always wrote "entries". Use the CLI's plural helper, as the catalog commands do, and test 1 and 2 entries. --- cli_report.go | 4 ++-- cli_report_test.go | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/cli_report.go b/cli_report.go index edfa0e3..5dcbb3a 100644 --- a/cli_report.go +++ b/cli_report.go @@ -77,10 +77,10 @@ func printReport(rep report.Report) { span = orDots(rep.From) + " – " + orDots(rep.To) } fmt.Printf("range\t%s\n", span) - fmt.Printf("hours\t%s\t%d entries\n", formatSeconds(rep.Seconds), rep.Entries) + fmt.Printf("hours\t%s\t%s\n", formatSeconds(rep.Seconds), plural(int64(rep.Entries), "entry", "entries")) fmt.Printf("earned\t$%.2f\tavg $%.2f/h\n", rep.Earned, rep.AverageRate) fmt.Printf("outstanding\t$%.2f\n", rep.Outstanding) - fmt.Printf("unbilled\t$%.2f\t%d entries\n", rep.Unbilled, rep.UnbilledEntries) + fmt.Printf("unbilled\t$%.2f\t%s\n", rep.Unbilled, plural(int64(rep.UnbilledEntries), "entry", "entries")) row := func(indent, name string, c report.Counts) { fmt.Printf("%s%s\t%s\t%d/%d invoiced\t%d/%d paid\t$%.2f\n", indent, flat.Replace(name), formatSeconds(c.Seconds), c.Invoiced, c.Entries, c.Paid, c.Entries, c.Earned) diff --git a/cli_report_test.go b/cli_report_test.go index 82e2d56..c5ad074 100644 --- a/cli_report_test.go +++ b/cli_report_test.go @@ -67,6 +67,23 @@ func TestReport_TextAndDefaults(t *testing.T) { } } +// The text output counts entries with the right noun: "1 entry", "2 entries" +// (ALI-2672). +func TestReport_TextPluralisesEntries(t *testing.T) { + path := seedRange(t) + for _, tc := range []struct{ day, hours, unbilled string }{ + {"2026-11-05", "hours\t2:00:00\t1 entry\n", "unbilled\t$170.00\t1 entry\n"}, + {"2026-11-02", "hours\t1:15:00\t2 entries\n", "unbilled\t$106.25\t2 entries\n"}, + } { + out := mustCLI(t, path, "report", "--from", tc.day, "--to", tc.day) + for _, want := range []string{tc.hours, tc.unbilled} { + if !strings.Contains(out, want) { + t.Errorf("%s: text report missing %q:\n%s", tc.day, want, out) + } + } + } +} + func TestReport_RejectsBadInput(t *testing.T) { path := emptyDB(t) failCLI(t, path, "use either -json or --csv", "report", "-json", "--csv")