-
-
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
Add examples for Default values for arguments #418
Comments
Since let s = matches.value_of("something").unwrap_or("default"); |
Sure, but if I'm accessing this in 5 places (say every time I'm checking verbosity), I'll have to define default value in those 5 places, and in documentation, and then make sure all those places are in sync. Having it defined once would be nicer. |
You don't have to define those default value in 5 different places, you'd just define one constant and use it over those five different places. I believe having default value has been brought up previously (#367 briefly). I think adding default value would be simple enough addition though I am skeptical if it is actually needed. Need @kbknapp to chime in. |
I'm not opposed to adding it, as with everything else in clap it'd be opt in and there's really no overhead to using it or it being there if you don't use it. Short of a quick cycle through the defaults if they're not already provided. Like @sru said I personally think there are ways get by without it, but it does seem to be something that I'm asked about from time to time. I'll add this to issue tracker for implementing. Thanks for taking the time to file this ;) |
I am also looking for default value support. This is what I do now:
Is there a better way? |
@jpastuszek The The next Edit: after the merge I'll upload v2.1.0 to crates.io |
@kbknapp is there any way we can get this added to the docs or the examples? I feel like this is a pretty useful feature, and it took me a while to find it. Is there an API reference available for the args commands? I'm loving this project so far. Thanks! |
@Drm2 absolutely! |
Wow. Incredible response time. Thank you! |
Its really excellent library, but I am missing ability to define default value for arguments. Could this be added?
The text was updated successfully, but these errors were encountered: