-
-
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
Printing help on bare command invocation #785
Comments
Thanks! You have a few options. You can either use The downside with the second approach is it returns a An example of the second version, should you choose that route would be: let matches = // build app like normal
.get_matches_from_safe_borrow(std::env:args_os())
.unwrap_or_else(|e| e.exit()) The Hope this helps! |
I used this way to create matches. It's like: let mut command = Command::new("ctool");
let matches = command.
.try_get_matches_from(std::env::args_os())
.unwrap_or_else(|e| e.exit()); And I want to use custom error, I did like this: let action_undefined_error = command.error(
clap::ErrorKind::InvalidValue,
"The given action is not supported, please enter base64, hex, etc."
); But it still gave: How to solve this. |
Options
|
Thank you, it worked. |
Thanks for this great library!
I've spent some time looking for the easiest path to tell clap show a full help message on a bare command invocation. (This is the behavior with commands such as
java
andcloc
.)These commands don't work:
I understand there are (at least) these options to make the API work as I intend:
app
before passing it toget_matches
.get_matches
that does not moveapp
. (I'm not sure if one exists.)I have a design question: What is the rationale for
get_matches
moving theapp
value? Perhaps a borrow would work out better?P.S. For some context, feel free to see: http://stackoverflow.com/questions/40951538/method-call-on-clap-app-moving-ownership-more-than-once
The text was updated successfully, but these errors were encountered: