From 999541544066dcc0c69736f7a6920978332d6f70 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk <martinvonz@google.com> Date: Wed, 28 Jun 2023 13:24:58 -0700 Subject: [PATCH] cli: propagate clap error from `handle_early_args()` If we fail to parse the command line, even with `ignore_errors(true)` set, we currently let clap exit the process for us because we call `get_matches_from()`. We should instead propagate any errors and exit in `CliRunner::run()` as usual.. --- src/cli_util.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli_util.rs b/src/cli_util.rs index e57f21238..257561aec 100644 --- a/src/cli_util.rs +++ b/src/cli_util.rs @@ -2280,7 +2280,7 @@ fn handle_early_args( layered_configs: &mut LayeredConfigs, ) -> Result<(), CommandError> { // ignore_errors() bypasses errors like "--help" or missing subcommand - let early_matches = app.clone().ignore_errors(true).get_matches_from(args); + let early_matches = app.clone().ignore_errors(true).try_get_matches_from(args)?; let mut args: EarlyArgs = EarlyArgs::from_arg_matches(&early_matches).unwrap(); if let Some(choice) = args.color {