feat(core): add launcher cli module

This commit is contained in:
Federico Terzi 2021-06-12 21:23:56 +02:00
parent 05920fbebc
commit 5e3491e238
3 changed files with 53 additions and 1 deletions

View File

@ -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 <https://www.gnu.org/licenses/>.
*/
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
}

View File

@ -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;

View File

@ -51,6 +51,7 @@ const LOG_FILE_NAME: &str = "espanso.log";
lazy_static! {
static ref CLI_HANDLERS: Vec<CliModule> = 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")