Skip to content

Commit 21a2a7c

Browse files
committed
feat(cli/chat): add shortcut for some slashcommands
1 parent 7cc0160 commit 21a2a7c

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

crates/rullm-cli/src/commands/chat/interactive.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,17 @@ pub async fn run_interactive_chat(
2222
"(Ctrl+C to exit)".dimmed()
2323
);
2424
println!(
25-
"{} Type {} for available commands.\n",
25+
"{} Type {} for available commands.",
2626
"Tip:".green(),
27-
"/help".yellow()
27+
"help".yellow()
2828
);
29+
println!(
30+
"{} Type {} or {} to exit.",
31+
"Tip:".green(),
32+
"exit".yellow(),
33+
"quit".yellow()
34+
);
35+
println!("");
2936

3037
let mut conversation = Vec::new();
3138
let mut line_editor = setup_reedline(config.config.vi_mode, &config.data_base_path)?;

crates/rullm-cli/src/commands/chat/slash_command.rs

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ pub enum SlashCommand {
1515

1616
impl 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

Comments
 (0)