From e572b93d84639498c6b646869ebf4e10098e8475 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Wed, 19 Jun 2024 16:25:36 -0700 Subject: [PATCH] Allow passing command-line arguments into `run()` (#2173) --- src/main.rs | 2 +- src/run.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index d580cde..6eebb25 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ fn main() { - if let Err(code) = just::run() { + if let Err(code) = just::run(std::env::args_os()) { std::process::exit(code); } } diff --git a/src/run.rs b/src/run.rs index 549a8fe..5d8cf83 100644 --- a/src/run.rs +++ b/src/run.rs @@ -2,7 +2,7 @@ use super::*; /// Main entry point into just binary. #[allow(clippy::missing_errors_doc)] -pub fn run() -> Result<(), i32> { +pub fn run(args: impl Iterator + Clone>) -> Result<(), i32> { #[cfg(windows)] ansi_term::enable_ansi_support().ok(); @@ -17,7 +17,7 @@ pub fn run() -> Result<(), i32> { let app = Config::app(); info!("Parsing command line arguments…"); - let matches = app.get_matches(); + let matches = app.get_matches_from(args); let config = Config::from_matches(&matches).map_err(Error::from);