@@ -15,6 +15,17 @@ pub enum SlashCommand {
15
15
16
16
impl SlashCommand {
17
17
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
+
18
29
let input = input. trim ( ) ;
19
30
if !input. starts_with ( '/' ) {
20
31
return None ;
@@ -74,12 +85,23 @@ pub async fn handle_slash_command(
74
85
Ok ( HandleCommandResult :: NoOp )
75
86
}
76
87
SlashCommand :: Help => {
88
+ println ! (
89
+ "{} {}" ,
90
+ "TIP:" . green( ) ,
91
+ "Some commands can be used without the leading '/'" . dimmed( )
92
+ ) ;
77
93
println ! ( "{}" , "Available commands:" . green( ) . bold( ) ) ;
78
94
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( ) ) ;
83
105
Ok ( HandleCommandResult :: NoOp )
84
106
}
85
107
SlashCommand :: Quit => Ok ( HandleCommandResult :: Quit ) ,
0 commit comments