Skip to content

Commit

Permalink
Fix error on help menu in builtins
Browse files Browse the repository at this point in the history
  • Loading branch information
Luxzi authored and lthoerner committed Sep 14, 2023
1 parent 5224b11 commit bceb71a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -763,9 +763,15 @@ macro_rules! file_err {
/// Shortcut for printing a `clap::Error` and returning a `BuiltinError::CouldNotParseArgs`
macro_rules! clap_handle {
($expr:expr) => {
$expr.map_err(|e| {
eprintln!("{}", e.render().ansi());
builtin_err!(CouldNotParseArgs)
})?
match $expr {
Ok(val) => val,
Err(e) => {
eprintln!("{}", e.render().ansi());
match e.kind() {
clap::error::ErrorKind::DisplayHelp => return crate::errors::Result::Ok(()),
_ => return crate::errors::Result::Err(builtin_err!(CouldNotParseArgs)),
}
},
}
};
}

0 comments on commit bceb71a

Please sign in to comment.