use `shellComplete instead of `ignoreErrors`, clean up

main
Roberto Hidalgo 5 years ago
parent f3295e3cdb
commit 9e7226ec28
No known key found for this signature in database
GPG Key ID: C4592BEB46817CC4

@ -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
}

Loading…
Cancel
Save