Skip to content

Commit

Permalink
Make more detailed error in Set
Browse files Browse the repository at this point in the history
  • Loading branch information
n10v committed Apr 26, 2017
1 parent 9421342 commit 4995a3e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,13 @@ func (f *FlagSet) Set(name, value string) error {
}
err := flag.Value.Set(value)
if err != nil {
return err
var flagName string
if len(flag.Shorthand) > 0 && len(flag.ShorthandDeprecated) == 0 {
flagName = fmt.Sprintf("-%s, --%s", flag.Shorthand, flag.Name)
} else {
flagName = fmt.Sprintf("--%s", flag.Name)
}
return fmt.Errorf("invalid argument %q for %q flag: %v", value, flagName, err)
}
if f.actual == nil {
f.actual = make(map[NormalizedName]*Flag)
Expand Down

0 comments on commit 4995a3e

Please sign in to comment.