From 9e7226ec28b02c14aab550c2028c33acb3439fa9 Mon Sep 17 00:00:00 2001 From: Roberto Hidalgo Date: Wed, 27 Nov 2019 11:45:44 -0500 Subject: [PATCH] use `shellComplete instead of `ignoreErrors`, clean up --- parse.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/parse.go b/parse.go index e77568d..7df1729 100644 --- a/parse.go +++ b/parse.go @@ -14,13 +14,13 @@ 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 @@ -28,7 +28,7 @@ func parseIter(set *flag.FlagSet, ip iterativeParser, args []string, ignoreError errStr := err.Error() trimmed := strings.TrimPrefix(errStr, "flag provided but not defined: -") - if !ignoreErrors && errStr == trimmed { + if errStr == trimmed { return err }