ok/jj
1
0
Fork 0
forked from mirrors/jj

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..
This commit is contained in:
Martin von Zweigbergk 2023-06-28 13:24:58 -07:00 committed by Martin von Zweigbergk
parent db87cb2c39
commit 9995415440

View file

@ -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 {