Skip to content
Myr

Update error message for missing required flags (#580)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Make it so that first letter is not capitalized and rephrase to remove "have/has".

authored by Nick Miyake · committed by Albert Nigmatzianov · parent 34ceca5 · Browse files · 2 files+3 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+3 added−3 removed

  • other:+3 added−3 removed

2 files+3 added−3 removed

modified:command_test.go+2 added-2 removed
679 unmodified lines
680 c.Flags().String("foo2", "", "")681 c.MarkFlagRequired("foo2")682 c.Flags().String("bar", "", "")683684 expected := fmt.Sprintf("Required flag(s) %q, %q have/has not been set", "foo1", "foo2")684 expected := fmt.Sprintf("required flag(s) %q, %q not set", "foo1", "foo2")685686 _, err := executeCommand(c)687 got := err.Error()688
18 unmodified lines
707 child.Flags().String("bar3", "", "")708709 parent.AddCommand(child)710711 expected := fmt.Sprintf("Required flag(s) %q, %q, %q, %q have/has not been set", "bar1", "bar2", "foo1", "foo2")711 expected := fmt.Sprintf("required flag(s) %q, %q, %q, %q not set", "bar1", "bar2", "foo1", "foo2")712713 _, err := executeCommand(parent, "child")714 if err.Error() != expected {715 t.Errorf("Expected %q, got %q", expected, err.Error())
793 unmodified lines
modified:command.go+1 added-1 removed
825 unmodified lines
826 }827 })828829 if len(missingFlagNames) > 0 {830 return fmt.Errorf(`Required flag(s) "%s" have/has not been set`, strings.Join(missingFlagNames, `", "`))830 return fmt.Errorf(`required flag(s) "%s" not set`, strings.Join(missingFlagNames, `", "`))831 }832 return nil833}834
580 unmodified lines