cli::command: wrap usage errors in a UsageError

So we can distinguish them and show usage output
conditionally.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2019-01-03 14:36:31 +01:00
parent c7fa487250
commit 4968bc3ac0
2 changed files with 28 additions and 14 deletions

View File

@ -146,7 +146,9 @@ fn main() {
if let Err(err) = run_cli_command(&cmd_def.into()) {
eprintln!("Error: {}", err);
print_cli_usage();
if err.downcast::<UsageError>().is_ok() {
print_cli_usage();
}
std::process::exit(-1);
}