diff --git a/Cargo.lock b/Cargo.lock index d42af848c9..89ca04b93a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3949,6 +3949,7 @@ dependencies = [ "tauri-plugin-fs", "tauri-plugin-hooks", "tauri-plugin-http", + "tauri-plugin-importer", "tauri-plugin-listener", "tauri-plugin-local-stt", "tauri-plugin-misc", @@ -14826,6 +14827,7 @@ version = "0.1.0" dependencies = [ "open", "serde", + "serde_json", "specta", "specta-typescript", "tauri", diff --git a/plugins/cli2/Cargo.toml b/plugins/cli2/Cargo.toml index 697e309e1b..6df15d8ea9 100644 --- a/plugins/cli2/Cargo.toml +++ b/plugins/cli2/Cargo.toml @@ -19,6 +19,7 @@ tauri-plugin-cli = { workspace = true } tauri-specta = { workspace = true, features = ["derive", "typescript"] } serde = { workspace = true } +serde_json = { workspace = true } specta = { workspace = true } open = { workspace = true } diff --git a/plugins/cli2/src/handler.rs b/plugins/cli2/src/handler.rs index b246d1306e..87745a5c84 100644 --- a/plugins/cli2/src/handler.rs +++ b/plugins/cli2/src/handler.rs @@ -1,7 +1,22 @@ +use serde_json::Value; use tauri::AppHandle; use tauri_plugin_cli::Matches; pub fn entrypoint(app: &AppHandle, matches: Matches) { + if let Some(arg) = matches.args.get("help") { + if let Value::String(help_text) = &arg.value { + print!("{help_text}"); + } + std::process::exit(0); + } + + if matches.args.contains_key("version") { + let name = &app.package_info().name; + let version = &app.package_info().version; + println!("{name} {version}"); + std::process::exit(0); + } + let version = app.package_info().version.to_string(); if let Some(subcommand_matches) = matches.subcommand { match subcommand_matches.name.as_str() {