From 5e3491e238ef0cdf42ab5d32ad239400cbe3528d Mon Sep 17 00:00:00 2001 From: Federico Terzi Date: Sat, 12 Jun 2021 21:23:56 +0200 Subject: [PATCH] feat(core): add launcher cli module --- espanso/src/cli/launcher/mod.rs | 49 +++++++++++++++++++++++++++++++++ espanso/src/cli/mod.rs | 1 + espanso/src/main.rs | 4 ++- 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 espanso/src/cli/launcher/mod.rs diff --git a/espanso/src/cli/launcher/mod.rs b/espanso/src/cli/launcher/mod.rs new file mode 100644 index 0000000..351d973 --- /dev/null +++ b/espanso/src/cli/launcher/mod.rs @@ -0,0 +1,49 @@ +/* + * This file is part of espanso. + * + * Copyright (C) 2019-2021 Federico Terzi + * + * espanso is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * espanso is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with espanso. If not, see . + */ + +use super::{CliModule, CliModuleArgs}; + +// TODO: test also with modulo feature disabled + +pub fn new() -> CliModule { + #[allow(clippy::needless_update)] + CliModule { + requires_paths: true, + enable_logs: false, + subcommand: "launcher".to_string(), + entry: launcher_main, + ..Default::default() + } +} + +#[cfg(feature = "modulo")] +fn launcher_main(args: CliModuleArgs) -> i32 { + let paths = args.paths.expect("missing paths in launcher main"); + let cli_args = args.cli_args.expect("missing cli_args in launcher main"); + let icon_paths = crate::icon::load_icon_paths(&paths.runtime).expect("unable to load icon paths"); + + espanso_modulo::wizard::show(); + + 0 +} + +#[cfg(not(feature = "modulo"))] +fn launcher_main(_: CliModuleArgs) -> i32 { + // TODO: handle what happens here +} diff --git a/espanso/src/cli/mod.rs b/espanso/src/cli/mod.rs index e27e3aa..87d0ecd 100644 --- a/espanso/src/cli/mod.rs +++ b/espanso/src/cli/mod.rs @@ -22,6 +22,7 @@ use espanso_config::{config::ConfigStore, matches::store::MatchStore}; use espanso_path::Paths; pub mod daemon; +pub mod launcher; pub mod log; pub mod migrate; pub mod modulo; diff --git a/espanso/src/main.rs b/espanso/src/main.rs index 80cf0bc..742d165 100644 --- a/espanso/src/main.rs +++ b/espanso/src/main.rs @@ -51,6 +51,7 @@ const LOG_FILE_NAME: &str = "espanso.log"; lazy_static! { static ref CLI_HANDLERS: Vec = vec![ cli::path::new(), + cli::launcher::new(), cli::log::new(), cli::worker::new(), cli::daemon::new(), @@ -152,6 +153,7 @@ fn main() { // .about("MacOS and Linux only. Register espanso in the system daemon manager.")) // .subcommand(SubCommand::with_name("unregister") // .about("MacOS and Linux only. Unregister espanso from the system daemon manager.")) + .subcommand(SubCommand::with_name("launcher").setting(AppSettings::Hidden)) .subcommand(SubCommand::with_name("log").about("Print the daemon logs.")) .subcommand( SubCommand::with_name("modulo") @@ -221,7 +223,7 @@ fn main() { ) .subcommand( SubCommand::with_name("migrate") - .about("Automatically migrate legacy config files to the new v2 format.") + .about("Automatically migrate legacy config files to the new v2 format."), ) // .subcommand(SubCommand::with_name("match") // .about("List and execute matches from the CLI")