pflag
pflag copied to clipboard
Add `PassUnknownFlagsToArgs` to allow get unknown flags via `Args()`
Close #337
FlagSet.ParseErrorsWhitelist.UnknownFlags=true behaves like this:
- Input:
-xayb -c -z --known-flag known-flag-value --unknown-flag arg0 arg1 arg2- -x, -y, -z and
--unknown-flagare unknown
- -x, -y, -z and
- Args():
arg1 arg2
This request adds FlagSet.ParseErrorsWhitelist.PassUnknownFlagsToArgs, and setting it to true results following behavior:
Args()withFlagSet.ParseErrorsWhitelist.PassUnknownFlagsToArgs=true:-xy -z --unknown-flag arg0 arg1 arg2
Any unknown and unprocessed flags are passed to Args().
@spf13 👋 Any chance of this landing? I have exactly this use-case as well :)
If it needs work, I would be happy to take it on