summaryrefslogtreecommitdiffstats
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 {
Delete(String),
TrackUp(String),
TrackDown(String),
+ Help(Option<String>),
Quit,
Blank,
}
#[derive(Debug)]
pub enum CommandLineError {
- InvalidCommand(String),
- InvalidArg(u32), // position
- NotEnoughArgs(String, u32),
+ InvalidCommand(String), // command name
+ InvalidArg(u32), // position
+ NotEnoughArgs(String, u32), // command name, required no. of args
}
impl std::error::Error for CommandLineError {}
@@ -134,6 +135,12 @@ impl Command {
}
return Ok(Command::TrackDown(args[0].to_string()));
}
+ "h" | "?" | "help" => {
+ if args.is_empty() {
+ return Ok(Command::Help(None));
+ }
+ return Ok(Command::Help(Some(args[0].to_string())));
+ }
"mprev" | "month-prev" => return Ok(Command::MonthPrev),
"mnext" | "month-next" => return Ok(Command::MonthNext),
"q" | "quit" => return Ok(Command::Quit),