-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
easy --no-switch complement to --switch #148
Comments
Here's the version of this from stack, which I think is pretty similar: https://github.com/commercialhaskell/stack/blob/0fa72bd825228d65f8e2c2b024d3fff0d7d792e7/src/Options/Applicative/Builder/Extra.hs#L36. Ours also accepts hidden |
In you example of foo = bar --switch, then foo --no-switch; this is monadic parsing as the order then becomes important. |
Huw Campbell wrote:
Order can be important in applicative parsing, no monads necessary. In my implementation sent to this bug, it's handled by getting a list of see shy jo |
Oh ok, you're using many (optparse provides its own version of many which uses bind instead of apply, it's the one bit using bind in there and I don't want to add any more). |
+1 Would love this feature. |
Ping. Has there been any decision whether such a feature would be accepted? |
A fairly common idiom in option parsing libraries is for --no-switch to be available as a way to disable an earlier --switch on the command line.
This is useful eg, when you have a shell alias foo = foo --switch, so foo --no-switch can be used to override . Another use case is to help future-proof a program; if it later changes so --switch is enabled by default, then users of both the old and the new version can use --no-switch to get the old behavior.
This is a bit clumsy to do with optparse-applicative, unless I'm missing an easy way to do it. Here's an implementation that makes it easy. I'd be happy if this or something like it were added to your library.
The text was updated successfully, but these errors were encountered: