From e6eb455f241cc4940ddf394287b7d59276304a64 Mon Sep 17 00:00:00 2001 From: Mike Wyatt Date: Sun, 22 Jun 2025 12:40:54 -0300 Subject: [PATCH] feedback changes --- .changes/add-optional-args-cli.md | 5 +++++ plugins/cli/src/lib.rs | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .changes/add-optional-args-cli.md diff --git a/.changes/add-optional-args-cli.md b/.changes/add-optional-args-cli.md new file mode 100644 index 00000000..6d4db171 --- /dev/null +++ b/.changes/add-optional-args-cli.md @@ -0,0 +1,5 @@ +--- +"cli": minor +--- + +Added `tauri_plugin_cli::matches_from`. This can be combined with the `args` passed to the callback of `tauri_plugin_single_instance` to parse the command line arguments passed to subsequent instances of the application. diff --git a/plugins/cli/src/lib.rs b/plugins/cli/src/lib.rs index df9fe75c..e927a348 100644 --- a/plugins/cli/src/lib.rs +++ b/plugins/cli/src/lib.rs @@ -28,8 +28,12 @@ pub use parser::{ArgData, Matches, SubcommandMatches}; pub struct Cli(PluginApi); impl Cli { - pub fn matches(&self, args: Option>) -> Result { - parser::get_matches(self.0.config(), self.0.app().package_info(), args) + pub fn matches(&self) -> Result { + parser::get_matches(self.0.config(), self.0.app().package_info(), None) + } + + pub fn matches_from(&self, args: Vec) -> Result { + parser::get_matches(self.0.config(), self.0.app().package_info(), Some(args)) } } @@ -45,7 +49,7 @@ impl> CliExt for T { #[tauri::command] fn cli_matches(_app: AppHandle, cli: State<'_, Cli>) -> Result { - cli.matches(None::>) + cli.matches() } pub fn init() -> TauriPlugin {