aliases: when invalid command found, let clap handle it

When we resolve aliases and we try to resolve something that is not a
real command and not an alias, we currently replicate `clap`'s error
message. I don't know why I did that because it seems that we should
just stop resolving aliases and let `clap` try to parse what we have
resolved at that point. This patch makes that change, thereby removing
an additional call to `process::exit()`.
This commit is contained in:
Martin von Zweigbergk 2022-09-24 07:15:23 -07:00 committed by Martin von Zweigbergk
parent 0484573a6d
commit cc30cb6ca8

View file

@ -1224,10 +1224,8 @@ fn resolve_aliases(
}
}
Err(config::ConfigError::NotFound(_)) => {
let mut app = app.clone();
app.error(clap::ErrorKind::ArgumentNotFound, format!(
r#"Found argument '{alias_name}' which wasn't expected, or isn't valid in this context"#
)).exit();
// Not a real command and not an alias, so return what we've resolved so far
return Ok(string_args);
}
Err(err) => {
return Err(CommandError::from(err));