Convert dump option to subcommand
This commit is contained in:
parent
812b8d9c05
commit
c899fa9f52
|
@ -59,13 +59,6 @@ impl MacContext {
|
|||
|
||||
context
|
||||
}
|
||||
|
||||
pub fn get_data_dir() -> PathBuf {
|
||||
let data_dir = dirs::data_dir().expect("Can't obtain data_dir(), terminating.");
|
||||
let espanso_dir = data_dir.join("espanso");
|
||||
create_dir_all(&espanso_dir).expect("Error creating espanso data directory");
|
||||
espanso_dir
|
||||
}
|
||||
}
|
||||
|
||||
impl super::Context for MacContext {
|
||||
|
|
|
@ -9,11 +9,20 @@ pub(crate) mod macos;
|
|||
|
||||
use std::sync::mpsc::Sender;
|
||||
use crate::event::Event;
|
||||
use std::path::PathBuf;
|
||||
use std::fs::create_dir_all;
|
||||
|
||||
pub trait Context {
|
||||
fn eventloop(&self);
|
||||
}
|
||||
|
||||
pub fn get_data_dir() -> PathBuf {
|
||||
let data_dir = dirs::data_dir().expect("Can't obtain data_dir(), terminating.");
|
||||
let espanso_dir = data_dir.join("espanso");
|
||||
create_dir_all(&espanso_dir).expect("Error creating espanso data directory");
|
||||
espanso_dir
|
||||
}
|
||||
|
||||
// MAC IMPLEMENTATION
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn new(send_channel: Sender<Event>) -> Box<dyn Context> {
|
||||
|
|
18
src/main.rs
18
src/main.rs
|
@ -40,15 +40,16 @@ fn main() {
|
|||
.value_name("FILE")
|
||||
.help("Sets a custom config directory. If not specified, reads the default $HOME/.espanso/default.yaml file, creating it if not present.")
|
||||
.takes_value(true))
|
||||
.arg(Arg::with_name("dump")
|
||||
.long("dump")
|
||||
.help("Prints all current configuration options."))
|
||||
.arg(Arg::with_name("v")
|
||||
.short("v")
|
||||
.multiple(true)
|
||||
.help("Sets the level of verbosity"))
|
||||
.subcommand(SubCommand::with_name("dump")
|
||||
.about("Prints all current configuration options."))
|
||||
.subcommand(SubCommand::with_name("detect")
|
||||
.about("Tool to detect current window properties, to simplify filters creation"))
|
||||
.about("Tool to detect current window properties, to simplify filters creation."))
|
||||
.subcommand(SubCommand::with_name("daemon")
|
||||
.about("Start the daemon without spawning a new process."))
|
||||
.get_matches();
|
||||
|
||||
|
||||
|
@ -87,7 +88,7 @@ fn main() {
|
|||
exit(1);
|
||||
});
|
||||
|
||||
if matches.is_present("dump") {
|
||||
if let Some(matches) = matches.subcommand_matches("dump") {
|
||||
println!("{:#?}", config_set);
|
||||
return;
|
||||
}
|
||||
|
@ -97,10 +98,15 @@ fn main() {
|
|||
return;
|
||||
}
|
||||
|
||||
if let Some(matches) = matches.subcommand_matches("daemon") {
|
||||
daemon_main(config_set);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fn daemon_main(config_set: ConfigSet) {
|
||||
info!("starting daemon...");
|
||||
|
||||
let (send_channel, receive_channel) = mpsc::channel();
|
||||
|
||||
let context = context::new(send_channel);
|
||||
|
@ -137,6 +143,8 @@ fn daemon_background(receive_channel: Receiver<Event>, config_set: ConfigSet) {
|
|||
vec!(&engine, &matcher),
|
||||
);
|
||||
|
||||
info!("espanso is running!");
|
||||
|
||||
event_manager.eventloop();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user