1
0
mirror of https://github.com/casey/just synced 2024-07-01 07:24:45 +00:00

Don't exit process in run() on argument parse error (#2176)

This commit is contained in:
Casey Rodarmor 2024-06-19 20:57:46 -07:00 committed by GitHub
parent aa43a664ee
commit e4564f45a3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,6 @@
use super::*;
/// Main entry point into `just`. Parse arguments from `args` and run. `run()`
/// will exit the proceess if `args` cannot be parsed.
/// Main entry point into `just`. Parse arguments from `args` and run.
#[allow(clippy::missing_errors_doc)]
pub fn run(args: impl Iterator<Item = impl Into<OsString> + Clone>) -> Result<(), i32> {
#[cfg(windows)]
@ -18,7 +17,10 @@ pub fn run(args: impl Iterator<Item = impl Into<OsString> + Clone>) -> Result<()
let app = Config::app();
info!("Parsing command line arguments…");
let matches = app.get_matches_from(args);
let matches = app.try_get_matches_from(args).map_err(|err| {
err.print().ok();
err.exit_code()
})?;
let config = Config::from_matches(&matches).map_err(Error::from);