From afb5ade2da60479aa4bf4892bf5d22c67aa2cf43 Mon Sep 17 00:00:00 2001 From: Mike Wyatt Date: Sat, 21 Jun 2025 14:53:42 -0300 Subject: [PATCH] add optional args to cli get_matches --- plugins/cli/src/lib.rs | 6 +++--- plugins/cli/src/parser.rs | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/plugins/cli/src/lib.rs b/plugins/cli/src/lib.rs index 3e144376..df9fe75c 100644 --- a/plugins/cli/src/lib.rs +++ b/plugins/cli/src/lib.rs @@ -28,8 +28,8 @@ pub use parser::{ArgData, Matches, SubcommandMatches}; pub struct Cli(PluginApi); impl Cli { - pub fn matches(&self) -> Result { - parser::get_matches(self.0.config(), self.0.app().package_info()) + pub fn matches(&self, args: Option>) -> Result { + parser::get_matches(self.0.config(), self.0.app().package_info(), args) } } @@ -45,7 +45,7 @@ impl> CliExt for T { #[tauri::command] fn cli_matches(_app: AppHandle, cli: State<'_, Cli>) -> Result { - cli.matches() + cli.matches(None::>) } pub fn init() -> TauriPlugin { diff --git a/plugins/cli/src/parser.rs b/plugins/cli/src/parser.rs index 64ec2fb7..25e12568 100644 --- a/plugins/cli/src/parser.rs +++ b/plugins/cli/src/parser.rs @@ -79,7 +79,11 @@ impl Matches { /// Ok(()) /// }); /// ``` -pub fn get_matches(cli: &Config, package_info: &PackageInfo) -> crate::Result { +pub fn get_matches( + cli: &Config, + package_info: &PackageInfo, + args: Option>, +) -> crate::Result { let about = cli .description() .unwrap_or(&package_info.description.to_string()) @@ -92,7 +96,17 @@ pub fn get_matches(cli: &Config, package_info: &PackageInfo) -> crate::Result Ok(get_matches_internal(cli, &matches)), Err(e) => match e.kind() { ErrorKind::DisplayHelp => {