CS110L-Lab/proj-1/deet/src/debugger_command.rs
2020-10-07 15:58:20 -07:00

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,
}
}
}