feat(core): port 'espanso status' subcommand. Fix #775
This commit is contained in:
parent
2d8e30525d
commit
2eabdf90bf
|
@ -95,6 +95,8 @@ fn service_main(args: CliModuleArgs) -> i32 {
|
|||
return start_main(&paths, &paths_overrides, sub_args);
|
||||
} else if cli_args.subcommand_matches("stop").is_some() {
|
||||
return stop_main(&paths);
|
||||
} else if cli_args.subcommand_matches("status").is_some() {
|
||||
return status_main(&paths);
|
||||
} else if let Some(sub_args) = cli_args.subcommand_matches("restart") {
|
||||
stop_main(&paths);
|
||||
return start_main(&paths, &paths_overrides, sub_args);
|
||||
|
@ -152,3 +154,15 @@ fn stop_main(paths: &Paths) -> i32 {
|
|||
|
||||
SERVICE_SUCCESS
|
||||
}
|
||||
|
||||
fn status_main(paths: &Paths) -> i32 {
|
||||
let lock_file = acquire_worker_lock(&paths.runtime);
|
||||
if lock_file.is_some() {
|
||||
error_eprintln!("espanso is not running");
|
||||
return SERVICE_NOT_RUNNING;
|
||||
}
|
||||
drop(lock_file);
|
||||
|
||||
info_println!("espanso is running");
|
||||
SERVICE_SUCCESS
|
||||
}
|
||||
|
|
|
@ -85,6 +85,10 @@ lazy_static! {
|
|||
subcommand: "stop".to_owned(),
|
||||
forward_into: "service".to_owned(),
|
||||
},
|
||||
CliAlias {
|
||||
subcommand: "status".to_owned(),
|
||||
forward_into: "service".to_owned(),
|
||||
},
|
||||
CliAlias {
|
||||
subcommand: "install".to_owned(),
|
||||
forward_into: "package".to_owned(),
|
||||
|
@ -171,6 +175,8 @@ fn main() {
|
|||
.about("Restart the espanso service")
|
||||
.name("restart");
|
||||
let stop_subcommand = SubCommand::with_name("stop").about("Stop espanso service");
|
||||
let status_subcommand =
|
||||
SubCommand::with_name("status").about("Check if the espanso daemon is running or not.");
|
||||
|
||||
let mut clap_instance = App::new("espanso")
|
||||
.version(VERSION)
|
||||
|
@ -299,12 +305,6 @@ For example, specifying 'email' is equivalent to 'match/email.yml'."#))
|
|||
),
|
||||
),
|
||||
)
|
||||
// .subcommand(SubCommand::with_name("start")
|
||||
// .about("Start the daemon spawning a new process in the background."))
|
||||
// .subcommand(SubCommand::with_name("stop")
|
||||
// .about("Stop the espanso daemon."))
|
||||
// .subcommand(SubCommand::with_name("restart")
|
||||
// .about("Restart the espanso daemon."))
|
||||
// .subcommand(SubCommand::with_name("status")
|
||||
// .about("Check if the espanso daemon is running or not."))
|
||||
.subcommand(
|
||||
|
@ -346,11 +346,13 @@ For example, specifying 'email' is equivalent to 'match/email.yml'."#))
|
|||
.subcommand(start_subcommand.clone())
|
||||
.subcommand(restart_subcommand.clone())
|
||||
.subcommand(stop_subcommand.clone())
|
||||
.subcommand(status_subcommand.clone())
|
||||
.about("Register and manage 'espanso' as a system service."),
|
||||
)
|
||||
.subcommand(start_subcommand)
|
||||
.subcommand(restart_subcommand)
|
||||
.subcommand(stop_subcommand)
|
||||
.subcommand(status_subcommand)
|
||||
// .subcommand(SubCommand::with_name("match")
|
||||
// .about("List and execute matches from the CLI")
|
||||
// .subcommand(SubCommand::with_name("list")
|
||||
|
|
Loading…
Reference in New Issue
Block a user