|
@ -1,9 +1,16 @@ |
|
|
pub fn parse_line(line: &str) -> (&str, Vec<&str>) {
|
|
|
pub fn parse_line(line: &str) -> (&str, Vec<&str>) {
|
|
|
let tokens = line.trim().split(' ').collect::<Vec<&str>>();
|
|
|
|
|
|
let mut args: Vec<&str> = Vec::new();
|
|
|
|
|
|
|
|
|
let tokens = tokenize(line);
|
|
|
|
|
|
|
|
|
let command = tokens[0];
|
|
|
let command = tokens[0];
|
|
|
|
|
|
let mut args: Vec<&str> = Vec::new();
|
|
|
|
|
|
|
|
|
if tokens.len() > 1 {
|
|
|
if tokens.len() > 1 {
|
|
|
args = tokens[1..].to_vec();
|
|
|
args = tokens[1..].to_vec();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
(command, args)
|
|
|
(command, args)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn tokenize(line: &str) -> Vec<&str> {
|
|
|
|
|
|
line.trim().split(' ').collect::<Vec<&str>>()
|
|
|
|
|
|
}
|