diff --git a/rust/app/src/app.rs b/rust/app/src/app.rs index d861f1d..e78cf0c 100644 --- a/rust/app/src/app.rs +++ b/rust/app/src/app.rs @@ -20,6 +20,9 @@ pub struct Options { pub theme: Option, /// Open a local terminal at startup and type this command once connected (testing aid). pub run_local: Option, + /// Open a window at startup: editor, quick, settings[:tab], keys, snippets, triggers, + /// recordings, palette, export, import (screenshot checks). + pub open: Option, } /// Errors from worker threads, drained into toasts each frame. @@ -129,6 +132,9 @@ impl App { run_local: opts.run_local.map(|c| (c, None)), resize_sidebar: false, }; + if let Some(w) = opts.open.as_deref() { + app.open_window(w); + } if let Some((_, sid)) = &mut app.run_local { let id = app.s.svc.connect_local(); *sid = Some(id.clone()); @@ -151,6 +157,33 @@ impl App { app } + fn open_window(&mut self, w: &str) { + let (w, arg) = w.split_once(':').unwrap_or((w, "")); + match w { + "editor" => match self.s.profiles.iter().find(|p| p.protocol.id() == arg || p.id == arg).map(|p| p.id.clone()) { + Some(id) => self.editor.open_edit(&self.s, &id), + None => self.editor.open_new(&self.s, Protocol::from_id(arg), ""), + }, + "quick" => self.quick.open(), + "settings" => self.settings.open(match arg { + "terminal" => SettingsTab::Terminal, + "security" => SettingsTab::Security, + "knownhosts" => SettingsTab::KnownHosts, + "help" => SettingsTab::Help, + "about" => SettingsTab::About, + _ => SettingsTab::General, + }), + "keys" => self.keys.open(), + "snippets" => self.snippets.open(), + "triggers" => self.triggers.open(), + "recordings" => self.recordings.open(), + "palette" => self.palette = Some(Default::default()), + "export" => self.transfer.export_encrypted(vec![]), + "import" => self.transfer.import_encrypted(), + _ => eprintln!("--open: unknown window {w:?}"), + } + } + // --- sessions ------------------------------------------------------------------------- fn view_for(&self, info: &SessionInfo, profile: Option<&Profile>) -> View { diff --git a/rust/app/src/main.rs b/rust/app/src/main.rs index 07c5e6f..4519310 100644 --- a/rust/app/src/main.rs +++ b/rust/app/src/main.rs @@ -33,7 +33,7 @@ use nexus_core::service::Service; use std::sync::Arc; fn main() -> eframe::Result { - let mut opts = app::Options { screenshot: None, theme: None, run_local: None }; + let mut opts = app::Options { screenshot: None, theme: None, run_local: None, open: None }; let mut size = [1360.0, 860.0]; let mut data_dir = None; let mut args = std::env::args().skip(1); @@ -41,6 +41,7 @@ fn main() -> eframe::Result { match a.as_str() { "--theme" => opts.theme = args.next(), "--run-local" => opts.run_local = args.next(), + "--open" => opts.open = args.next(), "--screenshot" => opts.screenshot = args.next().map(Into::into), // Use another data directory (testing, screenshots, portable installs). "--data-dir" => data_dir = args.next(),