aboutsummaryrefslogtreecommitdiff
path: root/src/command.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/command.rs')
-rw-r--r--src/command.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/command.rs b/src/command.rs
index f856b00..29908f4 100644
--- a/src/command.rs
+++ b/src/command.rs
@@ -59,15 +59,16 @@ pub enum Command {
59 Delete(String), 59 Delete(String),
60 TrackUp(String), 60 TrackUp(String),
61 TrackDown(String), 61 TrackDown(String),
62 Help(Option<String>),
62 Quit, 63 Quit,
63 Blank, 64 Blank,
64} 65}
65 66
66#[derive(Debug)] 67#[derive(Debug)]
67pub enum CommandLineError { 68pub enum CommandLineError {
68 InvalidCommand(String), 69 InvalidCommand(String), // command name
69 InvalidArg(u32), // position 70 InvalidArg(u32), // position
70 NotEnoughArgs(String, u32), 71 NotEnoughArgs(String, u32), // command name, required no. of args
71} 72}
72 73
73impl std::error::Error for CommandLineError {} 74impl std::error::Error for CommandLineError {}
@@ -134,6 +135,12 @@ impl Command {
134 } 135 }
135 return Ok(Command::TrackDown(args[0].to_string())); 136 return Ok(Command::TrackDown(args[0].to_string()));
136 } 137 }
138 "h" | "?" | "help" => {
139 if args.is_empty() {
140 return Ok(Command::Help(None));
141 }
142 return Ok(Command::Help(Some(args[0].to_string())));
143 }
137 "mprev" | "month-prev" => return Ok(Command::MonthPrev), 144 "mprev" | "month-prev" => return Ok(Command::MonthPrev),
138 "mnext" | "month-next" => return Ok(Command::MonthNext), 145 "mnext" | "month-next" => return Ok(Command::MonthNext),
139 "q" | "quit" => return Ok(Command::Quit), 146 "q" | "quit" => return Ok(Command::Quit),