Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/run.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand All @@ -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);

Expand Down