-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add "--no-flag" support for Boolean types #76
Comments
I'd love to help with this one ❤️ |
@immykins We would love for you to help with this! It might get a little tricky diving into the codebase the first time, but hopefully we can give you some direction on how to get started. One thing to be aware of is that configuration state of a CLI option should most likely live in the instance of the "type" that represents that CLI option (e.g. in the For this issue, I kinda think we should add a A couple things we'll need to address during this implementation:
Hopefully I can provide some example code in the near future to help get you started. In the meantime, feel free to ask questions or post comments in this issue. Thanks again for your interest in contributing to sywac! |
Thanks for the detailed information! I'm thinking of tackling this as a few smaller PRs (adding tests for |
Okay, I have some tests in place for this. A few questions: Let's say that a user has defined a boolean: My understanding is that if the parsed string doesn't use that boolean flag then it's set to Implementation questions: If a boolean has an alias, should enabling How should we handle the case where both the flag and its negation are used simultaneously? My instinct would be to just fail with an error message. |
@immykins Good questions! In the terms of the use-case, I think supporting
When configured, I think all aliases of the boolean option should support the negation prefix, but I would expect the use of a negation prefix to only work via a double-dash prefix, meaning I would expect
Each flag is encountered and parsed serially, so, for a boolean option, I would expect the last encountered value to "win". This should be consistent with current functionality when something like |
SUMMARY
In many popular CLI frameworks, having a boolean flag
--example
also allows--no-example
, as an alias for--example false
. Sywac should support the same input for boolean flags.DETAILS
We'll need to update the
boolean
type to slurp up this alternate alias, and make sure that it is handled properly when strict mode is turned on.The text was updated successfully, but these errors were encountered: