From cc30cb6ca8f2fad5007e2c7e68338312110a35e3 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 24 Sep 2022 07:15:23 -0700 Subject: [PATCH] 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()`. --- src/cli_util.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/cli_util.rs b/src/cli_util.rs index 822e9e920..38f46d333 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -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));