-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
optional takes_value
#367
Comments
@lipanski Thanks for suggesting this! I think this isn't a bad idea with a few changes to your proposal.
So I'll place it on the map to add 0 or more values, because this does seem to be something people ask about from time to time. Thanks again for taking the time to file this! 👍 |
didn't really think about that :\ would positional arguments take precedence over key arguments in that case?
I totally agree - that was just an example / my own use case.
Under which conditions would this evaluate to None / the default? Given:
And given:
thanks for your quick reply and for considering this! |
Ah ok, you're talking about with required arguments having default values. That in particular isn't possible yet, and I have mixed feelings on if it'd be a good idea or not. I would say it'd probably be better idea to to not make the argument required if you want it to have a default value. Because if the user leaves it off, it uses the default value, but if the user uses it, it still has a value. So there's not really a circumstance where it doesn't have a value (making the requirement piece less needed).
The way What would happen in that case is the positional argument would end up being stored as a value to that option. This can be mitigated by designing the CLI so that there either are no positional arguments, or all options take at least one value (even if it's empty). This is why I'm ok with implementing this feature, because the default will still be 1 or more values, but if the consumer of the library knows that they either have no positional values, or isn't concerned about the possible confusion, they can opt out by specifying a |
Closed with #386 |
💃 thx |
hello!
is there a way to make
takes_value
optional? if you think it's fairly easy and you'd like to include this as a feature, I could look into that myself.in my little script I imagined the following syntax:
I know about the
empty_vals
flag but I was just wondering if there would be a way to not pass the empty string every time.thanks! 🍰
The text was updated successfully, but these errors were encountered: