diff options
| -rw-r--r-- | src/command.rs | 9 | ||||
| -rw-r--r-- | src/main.rs | 18 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/command.rs b/src/command.rs index 283a47e..fbc714c 100644 --- a/src/command.rs +++ b/src/command.rs @@ -4,8 +4,12 @@ use structopt::StructOpt; #[derive(StructOpt, Debug)] #[structopt( rename_all = "kebab-case", - template = "Try one of these commands:\n{subcommands}", - raw(global_settings = "&[VersionlessSubcommands, ColorNever]",) + template = "{subcommands}", + raw(global_settings = "&[VersionlessSubcommands, + DisableHelpFlags, + DisableVersion, + ColorNever, + NoBinaryName]",) )] pub enum Command { /// Adds url to playlist @@ -17,6 +21,7 @@ pub enum Command { /// Stops audio playback Stop, /// Switches to the next queue entry + #[structopt(alias = "skip")] Next, /// Clears the playback queue Clear, diff --git a/src/main.rs b/src/main.rs index 0ba8e34..d1b34df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -170,14 +170,16 @@ impl Application { async fn on_text(&self, message: Message) -> Result<(), AudioPlayerError> { let msg = message.text; - if msg.starts_with("poke") { - let tokens = msg.split_whitespace().collect::<Vec<_>>(); - - let args = Command::from_iter_safe(&tokens); - match args { - Ok(v) => self.on_command(v).await?, - Err(e) => self.send_message(&format!("\n{}", e.message)), - }; + if msg.starts_with("!") { + let tokens = msg[1..].split_whitespace().collect::<Vec<_>>(); + + match Command::from_iter_safe(&tokens) { + Ok(args) => self.on_command(args).await?, + Err(e) if e.kind == structopt::clap::ErrorKind::HelpDisplayed => { + self.send_message(&format!("\n{}", e.message)); + } + _ => (), + } } Ok(()) |
