Fix CLI token set command
This commit is contained in:
@@ -42,7 +42,6 @@ func NewSet(name, envPrefix string) *Set {
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *Set) Args() []string { return s.fs.Args() }
|
||||
func (s *Set) SetOutput(w io.Writer) { s.fs.SetOutput(w) }
|
||||
func (s *Set) register(sp *spec) { s.specs = append(s.specs, sp) }
|
||||
func (s *Set) note(long, short string) {
|
||||
@@ -208,7 +207,19 @@ func (s *Set) Parse(args []string) error {
|
||||
if err := s.checkConvention(args); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.fs.Parse(args)
|
||||
if err := s.fs.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
// A stray word is never harmless: the flag package stops parsing at the
|
||||
// first non-flag argument, so every option after it is dropped in silence.
|
||||
// Writing a boolean as "--vanity false" is the way this bites - it sets
|
||||
// the flag to true and then discards the --data that says which file to
|
||||
// write, leaving a cheerful message about the opposite of what was meant.
|
||||
if extra := s.fs.Args(); len(extra) > 0 {
|
||||
return fmt.Errorf("unexpected argument %q: an option's value attaches with %q, as in --name=value, and any positional argument comes first",
|
||||
extra[0], "=")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Changed reports whether an option was given on the command line.
|
||||
|
||||
Reference in New Issue
Block a user