pflag icon indicating copy to clipboard operation
pflag copied to clipboard

Preserve unknown flags

Open ikedam opened this issue 3 years ago • 1 comments

FlagSet.ParseErrorsWhitelist.UnknownFlags ignores unknown flags, but throws away them. I want pflag just skip them and pass them to Args().

Input:

--known-flag known-flag-value --unknown-flag arg0 arg1 arg2

Current output via Args():

arg1 arg2

arg0 is treated as value for unknown-flag-value

Wanted output via Args():

--unknown-flag arg0 arg1 arg2

Background: I want to create a utility wrapper for existing command. It accepts extra flags and change how to call the command. It's used like this:

mygrep --my-extra-flag1 --my-extra-flag2 my-extra-flag2-value -i -e search-text file1 file2

ikedam avatar Dec 11 '21 07:12 ikedam

This is a nice-to-have feature. I'm wondering why no one is reviewing this

nhatthm avatar Aug 10 '22 09:08 nhatthm