pcapriotti / optparse-applicative

Applicative option parser
BSD 3-Clause "New" or "Revised" License
910 stars 116 forks source link

Ignore unused flags #464

Closed eyeinsky closed 1 year ago

eyeinsky commented 1 year ago

Admitting that it's probably bad to have this in production code, is there a way to ignore flags and switches that are provided on the command line but not actually required? The use case is that while developing a program with several sub-commands which use mostly-but-not-entirely common set of flags and having test scripts to run these then I wouldn't need to add/remove flags whenever I change cli definition.

This feature doesn't seem to be in the ParserPrefs.

Is there a way to achieve the same effect through some usage pattern?

HuwCampbell commented 1 year ago

I'm not sure I follow.

Do you mean is there a way in which we should ignore options which aren't specified in the parser definition but are given by the user? I don't think that's possible really, because we wouldn't know if they meant an option or a flag and a positional if we don't have it specified. It would also be pretty savage.

If you have common options you can put them on the top layer as globals and just not use all of them in an individual sub command. To make the experience nicer you might want to turn on subparser inline.

eyeinsky commented 1 year ago

Was afraid that the answer something on the lines of "not really possible". :p

I'll have to look into subparser inline, thanks!