aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno A. Muciño <[email protected]>2020-09-02 05:31:42 +0100
committerBruno A. Muciño <[email protected]>2020-09-02 05:31:42 +0100
commiteb890f1cc649f8f250ac83a3f5510d91587a4a8d (patch)
tree0f68a5b3cfeee5a3f43ab4e2e6dfc648dc1bc61f
parent8529b270c4023608d86ab4b98c915970a98ec6f4 (diff)
Adds "wq" command as a combination of "write" and "quit".
-rw-r--r--src/app/impl_self.rs2
-rw-r--r--src/command.rs8
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 {
249 "tdown" | "track-down" => "track-down <auto-habit-name> (alias: tdown)", 249 "tdown" | "track-down" => "track-down <auto-habit-name> (alias: tdown)",
250 "q" | "quit" => "quit dijo", 250 "q" | "quit" => "quit dijo",
251 "w" | "write" => "write current state to disk (alias: w)", 251 "w" | "write" => "write current state to disk (alias: w)",
252 "wq" | "writeandquit" => "write current state to disk and quit dijo (alias: wq)",
252 "h"|"?" | "help" => "help [<command>|commands|keys] (aliases: h, ?)", 253 "h"|"?" | "help" => "help [<command>|commands|keys] (aliases: h, ?)",
253 "cmds" | "commands" => "add, add-auto, delete, month-{prev,next}, track-{up,down}, help, quit", 254 "cmds" | "commands" => "add, add-auto, delete, month-{prev,next}, track-{up,down}, help, quit",
254 "keys" => "TODO", // TODO (view?) 255 "keys" => "TODO", // TODO (view?)
@@ -260,6 +261,7 @@ impl App {
260 self.message.set_message("help <command>|commands|keys") 261 self.message.set_message("help <command>|commands|keys")
261 } 262 }
262 } 263 }
264 Command::WriteAndQuit => self.save_state(),
263 Command::Quit | Command::Write => self.save_state(), 265 Command::Quit | Command::Write => self.save_state(),
264 Command::MonthNext => self.sift_forward(), 266 Command::MonthNext => self.sift_forward(),
265 Command::MonthPrev => self.sift_backward(), 267 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] = &[
20 "quit", 20 "quit",
21 "write", 21 "write",
22 "help", 22 "help",
23 "writeandquit",
23]; 24];
24 25
25fn get_command_completion(prefix: &str) -> Option<String> { 26fn get_command_completion(prefix: &str) -> Option<String> {
@@ -98,8 +99,9 @@ fn call_on_app(s: &mut Cursive, input: &str) {
98 // our main cursive object, has to be parsed again 99 // our main cursive object, has to be parsed again
99 // here 100 // here
100 // TODO: fix this somehow 101 // TODO: fix this somehow
101 if let Ok(Command::Quit) = Command::from_string(input) { 102 match Command::from_string(input) {
102 s.quit(); 103 Ok(Command::Quit) | Ok(Command::WriteAndQuit) => s.quit(),
104 _ => {}
103 } 105 }
104} 106}
105 107
@@ -115,6 +117,7 @@ pub enum Command {
115 Write, 117 Write,
116 Quit, 118 Quit,
117 Blank, 119 Blank,
120 WriteAndQuit,
118} 121}
119 122
120#[derive(Debug)] 123#[derive(Debug)]
@@ -196,6 +199,7 @@ impl Command {
196 } 199 }
197 "mprev" | "month-prev" => return Ok(Command::MonthPrev), 200 "mprev" | "month-prev" => return Ok(Command::MonthPrev),
198 "mnext" | "month-next" => return Ok(Command::MonthNext), 201 "mnext" | "month-next" => return Ok(Command::MonthNext),
202 "wq" | "writeandquit" => return Ok(Command::WriteAndQuit),
199 "q" | "quit" => return Ok(Command::Quit), 203 "q" | "quit" => return Ok(Command::Quit),
200 "w" | "write" => return Ok(Command::Write), 204 "w" | "write" => return Ok(Command::Write),
201 "" => return Ok(Command::Blank), 205 "" => return Ok(Command::Blank),