This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
Update pflag to avoid flag parsing gotchas #1183
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
github.com/spf13/pflag has moderately wacky error handling, which it
probably inherited from
flag
in stdlib.You can either choose to let it handle flag parsing errors for you, by
printing the error and usage then exiting (
ExitOnError
); or, returnthem to you so you can decide what to do (
ContinueOnError
).The revision of pflag we were using (in the first mode) was silent in
the case that parsing a flag value failed -- so we changed to use
the second mode, and handled errors by printing the usage
ourselves. However, it wasn't silent in other cases, meaning we would
output the usage twice (including if you used the
--help
flag).The newer revision of pflag 1. doesn't output usage if you've told it
you'll handle errors, and 2. doesn't remain silent when it fails to
parse a value. So it would work for us in either mode; since we're
already using ContinueOnError, just tidy that up.
Fixes #1176.