diff options
author | Bruno A. Muciño <mucinoab@gmail.com> | 2020-09-01 23:31:42 -0500 |
---|---|---|
committer | Bruno A. Muciño <mucinoab@gmail.com> | 2020-09-01 23:31:42 -0500 |
commit | eb890f1cc649f8f250ac83a3f5510d91587a4a8d (patch) | |
tree | 0f68a5b3cfeee5a3f43ab4e2e6dfc648dc1bc61f | |
parent | 8529b270c4023608d86ab4b98c915970a98ec6f4 (diff) |
Adds "wq" command as a combination of "write" and "quit".
-rw-r--r-- | src/app/impl_self.rs | 2 | ||||
-rw-r--r-- | src/command.rs | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs index 5cd9616..ce99702 100644 --- a/src/app/impl_self.rs +++ b/src/app/impl_self.rs @@ -249,6 +249,7 @@ impl App { "tdown" | "track-down" => "track-down <auto-habit-name> (alias: tdown)", "q" | "quit" => "quit dijo", "w" | "write" => "write current state to disk (alias: w)", + "wq" | "writeandquit" => "write current state to disk and quit dijo (alias: wq)", "h"|"?" | "help" => "help [<command>|commands|keys] (aliases: h, ?)", "cmds" | "commands" => "add, add-auto, delete, month-{prev,next}, track-{up,down}, help, quit", "keys" => "TODO", // TODO (view?) @@ -260,6 +261,7 @@ impl App { self.message.set_message("help <command>|commands|keys") } } + Command::WriteAndQuit => self.save_state(), Command::Quit | Command::Write => self.save_state(), Command::MonthNext => self.sift_forward(), Command::MonthPrev => self.sift_backward(), diff --git a/src/command.rs b/src/command.rs index 4f3e491..30aabe2 100644 --- a/src/command.rs +++ b/src/command.rs @@ -20,6 +20,7 @@ static COMMANDS: &'static [&'static str] = &[ "quit", "write", "help", + "writeandquit", ]; fn get_command_completion(prefix: &str) -> Option<String> { @@ -98,8 +99,9 @@ fn call_on_app(s: &mut Cursive, input: &str) { // our main cursive object, has to be parsed again // here // TODO: fix this somehow - if let Ok(Command::Quit) = Command::from_string(input) { - s.quit(); + match Command::from_string(input) { + Ok(Command::Quit) | Ok(Command::WriteAndQuit) => s.quit(), + _ => {} } } @@ -115,6 +117,7 @@ pub enum Command { Write, Quit, Blank, + WriteAndQuit, } #[derive(Debug)] @@ -196,6 +199,7 @@ impl Command { } "mprev" | "month-prev" => return Ok(Command::MonthPrev), "mnext" | "month-next" => return Ok(Command::MonthNext), + "wq" | "writeandquit" => return Ok(Command::WriteAndQuit), "q" | "quit" => return Ok(Command::Quit), "w" | "write" => return Ok(Command::Write), "" => return Ok(Command::Blank), |