@@ -15,6 +15,17 @@ pub enum SlashCommand {
1515
1616impl SlashCommand {
1717 pub ( crate ) fn parse ( input : & str ) -> Option < Self > {
18+ // special case for some shortcuts
19+ if input. len ( ) <= 5 {
20+ match input. to_lowercase ( ) . as_str ( ) {
21+ "quit" | "exit" => return Some ( SlashCommand :: Quit ) ,
22+ "help" => return Some ( SlashCommand :: Help ) ,
23+ "reset" => return Some ( SlashCommand :: Reset ) ,
24+ "edit" => return Some ( SlashCommand :: Edit ) ,
25+ _ => { }
26+ }
27+ }
28+
1829 let input = input. trim ( ) ;
1930 if !input. starts_with ( '/' ) {
2031 return None ;
@@ -74,12 +85,23 @@ pub async fn handle_slash_command(
7485 Ok ( HandleCommandResult :: NoOp )
7586 }
7687 SlashCommand :: Help => {
88+ println ! (
89+ "{} {}" ,
90+ "TIP:" . green( ) ,
91+ "Some commands can be used without the leading '/'" . dimmed( )
92+ ) ;
7793 println ! ( "{}" , "Available commands:" . green( ) . bold( ) ) ;
7894 println ! ( " {} - Set system prompt" , "/system <message>" . yellow( ) ) ;
79- println ! ( " {} - Clear conversation history" , "/reset" . yellow( ) ) ;
80- println ! ( " {} - Show this help" , "/help" . yellow( ) ) ;
81- println ! ( " {} - Edit next message in $EDITOR" , "/edit" . yellow( ) ) ;
82- println ! ( " {} - Exit chat" , "/quit or /exit" . yellow( ) ) ;
95+ println ! (
96+ " {} - Clear conversation history" ,
97+ "/reset (reset)" . yellow( )
98+ ) ;
99+ println ! ( " {} - Show this help" , "/help (help)" . yellow( ) ) ;
100+ println ! (
101+ " {} - Edit next message in $EDITOR" ,
102+ "/edit (edit)" . yellow( )
103+ ) ;
104+ println ! ( " {} - Exit chat" , "/quit or /exit (quit or exit)" . yellow( ) ) ;
83105 Ok ( HandleCommandResult :: NoOp )
84106 }
85107 SlashCommand :: Quit => Ok ( HandleCommandResult :: Quit ) ,
0 commit comments