Skip to content

Commit

Permalink
use shellComplete instead of ignoreErrors`, clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Hidalgo committed Nov 27, 2019
1 parent f3295e3 commit 9e7226e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions parse.go
Expand Up @@ -14,21 +14,21 @@ type iterativeParser interface {
// iteratively catch parsing errors. This way we achieve LR parsing without
// transforming any arguments. Otherwise, there is no way we can discriminate
// combined short options from common arguments that should be left untouched.
// Pass `ignoreErrors` to continue parsing options on failure, for example
// during shell completion when the user-supplied options may be incomplete.
func parseIter(set *flag.FlagSet, ip iterativeParser, args []string, ignoreErrors bool) error {
// Pass `shellComplete` to continue parsing options on failure during shell
// completion when, the user-supplied options may be incomplete.
func parseIter(set *flag.FlagSet, ip iterativeParser, args []string, shellComplete bool) error {
for {
err := set.Parse(args)
if !ip.useShortOptionHandling() || err == nil {
if ignoreErrors {
if shellComplete {
return nil
}
return err
}

errStr := err.Error()
trimmed := strings.TrimPrefix(errStr, "flag provided but not defined: -")
if !ignoreErrors && errStr == trimmed {
if errStr == trimmed {
return err
}

Expand Down

0 comments on commit 9e7226e

Please sign in to comment.