diff --git a/src/parse.rs b/src/parse.rs index cda4f05..ceef7e8 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -1,9 +1,16 @@ pub fn parse_line(line: &str) -> (&str, Vec<&str>) { - let tokens = line.trim().split(' ').collect::>(); - let mut args: Vec<&str> = Vec::new(); + let tokens = tokenize(line); + let command = tokens[0]; + let mut args: Vec<&str> = Vec::new(); + if tokens.len() > 1 { args = tokens[1..].to_vec(); } + (command, args) } + +fn tokenize(line: &str) -> Vec<&str> { + line.trim().split(' ').collect::>() +} \ No newline at end of file