21 lines
530 B
Rust
21 lines
530 B
Rust
pub enum DebuggerCommand {
|
|
Quit,
|
|
Run(Vec<String>),
|
|
}
|
|
|
|
impl DebuggerCommand {
|
|
pub fn from_tokens(tokens: &Vec<&str>) -> Option<DebuggerCommand> {
|
|
match tokens[0] {
|
|
"q" | "quit" => Some(DebuggerCommand::Quit),
|
|
"r" | "run" => {
|
|
let args = tokens[1..].to_vec();
|
|
Some(DebuggerCommand::Run(
|
|
args.iter().map(|s| s.to_string()).collect(),
|
|
))
|
|
}
|
|
// Default case:
|
|
_ => None,
|
|
}
|
|
}
|
|
}
|