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

Better error message if a user doesn't specify any arguments #38

Open
ssokolow opened this issue Jul 22, 2018 · 0 comments
Open

Better error message if a user doesn't specify any arguments #38

ssokolow opened this issue Jul 22, 2018 · 0 comments

Comments

@ssokolow
Copy link

ssokolow@monolith rdbackup-excludes-indexer [master] %% cargo profiler     
error: Invalid profiler. cargo profiler currently supports callgrind and cachegrind.

Referring to "no profiler" as an invalid profiler is one of those things that only makes sense to a computer.

The error message should be one of the following in this case:

  • error: You must specify a profiler.
  • USAGE: cargo profiler <SUBCOMMAND>
  • The output of cargo profiler --help

Also, I noticed that your actual USAGE: doesn't use < and > to specify that the subcommand is mandatory.

I can't double-check, since I get an error in rustc-serialize when I attempt to build your git HEAD, but I think you can just add .required(true) to the subcommand argument to get a more helpful error message automatically, plus the appropriate <SUBCOMMAND> in your --help rather than [SUBCOMMAND].

(I'm not 100% certain because I use subcommands infrequently enough in my projects that the last time I defined one was back when clap didn't exist and I was working with argparse and Python.)

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

No branches or pull requests

1 participant