forked from mirror/cobra
Update error message for missing required flags (#580)
Make it so that first letter is not capitalized and rephrase to remove "have/has".
This commit is contained in:
parent
34ceca591b
commit
19e54c4a2b
|
@ -827,7 +827,7 @@ func (c *Command) validateRequiredFlags() error {
|
|||
})
|
||||
|
||||
if len(missingFlagNames) > 0 {
|
||||
return fmt.Errorf(`Required flag(s) "%s" have/has not been set`, strings.Join(missingFlagNames, `", "`))
|
||||
return fmt.Errorf(`required flag(s) "%s" not set`, strings.Join(missingFlagNames, `", "`))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -681,7 +681,7 @@ func TestRequiredFlags(t *testing.T) {
|
|||
c.MarkFlagRequired("foo2")
|
||||
c.Flags().String("bar", "", "")
|
||||
|
||||
expected := fmt.Sprintf("Required flag(s) %q, %q have/has not been set", "foo1", "foo2")
|
||||
expected := fmt.Sprintf("required flag(s) %q, %q not set", "foo1", "foo2")
|
||||
|
||||
_, err := executeCommand(c)
|
||||
got := err.Error()
|
||||
|
@ -708,7 +708,7 @@ func TestPersistentRequiredFlags(t *testing.T) {
|
|||
|
||||
parent.AddCommand(child)
|
||||
|
||||
expected := fmt.Sprintf("Required flag(s) %q, %q, %q, %q have/has not been set", "bar1", "bar2", "foo1", "foo2")
|
||||
expected := fmt.Sprintf("required flag(s) %q, %q, %q, %q not set", "bar1", "bar2", "foo1", "foo2")
|
||||
|
||||
_, err := executeCommand(parent, "child")
|
||||
if err.Error() != expected {
|
||||
|
|
Loading…
Reference in New Issue