Skip to content
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

Enhancement: Handle syntax --[no-]cheese #2213

Closed
fodil-a-mindflow opened this issue Jun 24, 2024 · 3 comments
Closed

Enhancement: Handle syntax --[no-]cheese #2213

fodil-a-mindflow opened this issue Jun 24, 2024 · 3 comments

Comments

@fodil-a-mindflow
Copy link

Hello,

I hope you're doing well! I just wanted to say that your library is fantastic. While working with it, I discovered that to create flags for both yes and no, I need to declare each one separately.

I was wondering if you might consider an enhancement to the syntax, such as using [no-], to automatically generate both commands with true/false values. 😃

I'd be happy to contribute by submitting a PR for this feature if you're interested.

Have a great day!

@shadowspawn
Copy link
Collaborator

Not sure quite what you have in mind. Would you see one option or two in the help?

For some historical background, the original support for a negated option (e.g. --no-cheese) was for a stand-alone option and it did not work as part of a yes/no pair of options.

Support was added in #795 to allow a yes/no pair of options to work nicely together, and extended in in #987 and #1652 for defaults and presets.

Now that we have a solid implementation, I am reluctant to add support for a single-option supporting both yes/no as an alternative way of implementing the same behaviour (#1355) without some compelling need or a lot of up-votes.

If you were thinking of an author shortcut for creating the pair of options with a single call, I think you could implement that with an override to Command.

@shadowspawn
Copy link
Collaborator

I noticed git uses this syntax in the synopsis for some of its boolean options, as well as other forms for options with an option-value:

clone
       --[no-]single-branch
push
       --[no-]signed, --signed=(true|false|if-asked)
       --[no-]atomic
       --[no-]force-with-lease, --force-with-lease=<refname>,
       --no-recurse-submodules, --recurse-submodules=check|on-demand|only|no
pull
       --[no-]recurse-submodules[=yes|on-demand|no]
       --log[=<n>], --no-log
branch
       --no-contains [<commit>]
       --no-merged [<commit>]

@shadowspawn
Copy link
Collaborator

An answer was provided, and no further activity in a few months. Closing this as resolved.

Feel free to open a new issue if it comes up again, with new information and renewed interest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants