#[derive(Debug, PartialEq)]
pub enum BridgeCommand {
Prompt { text: String },
NewSession,
Status,
Help,
UseWorkspace { name: String },
}
impl BridgeCommand {
pub fn parse(text: &str) -> Self {
let trimmed = text.trim();
match trimmed {
"/new" => BridgeCommand::NewSession,
"/status" => BridgeCommand::Status,
"/help" => BridgeCommand::Help,
other if other.starts_with("/use ") => {
let name = other["/use ".len()..].trim().to_string();
BridgeCommand::UseWorkspace { name }
}
other => BridgeCommand::Prompt {
text: other.to_string(),
},
}
}
}
#[cfg(test)]
#[path = "../tests/command_test.rs"]
mod tests;