stynx_code_commands/application/
parse_command.rs1use crate::domain::SlashCommand;
2
3pub fn parse_command(input: &str) -> Option<SlashCommand> {
4 let trimmed = input.trim();
5
6 match trimmed {
7 "/help" => return Some(SlashCommand::Help),
8 "/clear" => return Some(SlashCommand::Clear),
9 "/compact" => return Some(SlashCommand::Compact),
10 "/cost" => return Some(SlashCommand::Cost),
11 "/quit" | "/exit" => return Some(SlashCommand::Quit),
12 "/diff" => return Some(SlashCommand::Diff),
13 "/status" => return Some(SlashCommand::Status),
14 "/doctor" => return Some(SlashCommand::Doctor),
15 "/config" => return Some(SlashCommand::Config),
16 "/permissions" => return Some(SlashCommand::Permissions),
17 "/plan" => return Some(SlashCommand::Plan),
18 "/usage" => return Some(SlashCommand::Usage),
19 "/mode" => return Some(SlashCommand::Mode),
20 "/model" => return Some(SlashCommand::Model(String::new())),
21 "/session" => return Some(SlashCommand::Session(String::new())),
22 "/think" => return Some(SlashCommand::Think),
23 "/files" => return Some(SlashCommand::Files),
24 "/memory" => return Some(SlashCommand::Memory),
25 "/export" => return Some(SlashCommand::Export),
26 "/review" => return Some(SlashCommand::Review),
27 "/commit" => return Some(SlashCommand::Commit),
28 "/fast" => return Some(SlashCommand::Fast),
29 "/effort" => return Some(SlashCommand::Effort(String::new())),
30 "/copy" => return Some(SlashCommand::Copy),
31 "/login" => return Some(SlashCommand::Login),
32 "/logout" => return Some(SlashCommand::Logout),
33 "/vim" => return Some(SlashCommand::Vim),
34 "/version" => return Some(SlashCommand::Version),
35 "/rewind" => return Some(SlashCommand::Rewind(1)),
36 _ => {}
37 }
38
39 if let Some(rest) = trimmed.strip_prefix("/model ") {
40 let name = rest.trim();
41 if !name.is_empty() {
42 return Some(SlashCommand::Model(name.to_string()));
43 }
44 }
45
46 if let Some(rest) = trimmed.strip_prefix("/session ") {
47 let id = rest.trim();
48 if !id.is_empty() {
49 return Some(SlashCommand::Session(id.to_string()));
50 }
51 }
52
53 if let Some(rest) = trimmed.strip_prefix("/add ") {
54 let path = rest.trim();
55 if !path.is_empty() {
56 return Some(SlashCommand::Add(path.to_string()));
57 }
58 }
59
60 if let Some(rest) = trimmed.strip_prefix("/rewind ") {
61 let n: usize = rest.trim().parse().unwrap_or(1);
62 return Some(SlashCommand::Rewind(n.max(1)));
63 }
64
65 if let Some(rest) = trimmed.strip_prefix("/effort ") {
66 let level = rest.trim().to_lowercase();
67 if !level.is_empty() {
68 return Some(SlashCommand::Effort(level));
69 }
70 }
71
72 None
73}