Add shared report format flag

This commit is contained in:
2026-11-07 03:45:12 +00:00
parent 3a6c66f550
commit 924692b541
18 changed files with 206 additions and 101 deletions

View File

@@ -5,7 +5,7 @@ import "testing"
func TestReportingFlagsAreBooleanAndReturnedIndependently(t *testing.T) {
flags := ReportingFlags()
want := []string{"quiet", "verbose", "debug", "progress"}
if len(flags) != len(want) {
if len(flags) != len(want)+1 {
t.Fatalf("reporting flags = %#v", flags)
}
for index, name := range want {
@@ -16,6 +16,13 @@ func TestReportingFlagsAreBooleanAndReturnedIndependently(t *testing.T) {
t.Errorf("%q is not recognized as a reporting flag", name)
}
}
if flags[4].Name != "format" || flags[4].Boolean || !IsReportingFlag("format") {
t.Fatalf("format metadata = %#v", flags[4])
}
flags[4].Completion.Choices[0].Value = "changed"
if ReportingFlags()[4].Completion.Choices[0].Value != "text" {
t.Fatal("caller mutation changed format choices")
}
flags[0].Name = "changed"
if ReportingFlags()[0].Name != "quiet" {
t.Fatal("caller mutation changed shared reporting metadata")