diff --git a/src/execute.rs b/src/execute.rs index 4cd84ba..43bd632 100644 --- a/src/execute.rs +++ b/src/execute.rs @@ -20,8 +20,8 @@ pub fn execute>(mut command: Command, stdin: S) -> io::Result<(Ch } pub fn interpret(line: &str) -> io::Result<()> { - let (command, args) = parse_line(line); - let mut command = Command::new(command); + let (keyword, args) = parse_line(line); + let mut command = Command::new(keyword); command.args(args); let (mut stdout, _) = execute(command, Stdio::null())?; io::copy(&mut stdout, &mut io::stdout())?; diff --git a/src/parse.rs b/src/parse.rs index 4d07452..c194120 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -1,14 +1,14 @@ pub fn parse_line(line: &str) -> (&str, Vec<&str>) { let tokens = tokenize(line); - let command = tokens[0]; + let keyword = tokens[0]; let mut args: Vec<&str> = Vec::new(); if tokens.len() > 1 { args = tokens[1..].to_vec(); } - (command, args) + (keyword, args) } fn tokenize(line: &str) -> Vec<&str> { @@ -22,16 +22,16 @@ mod tests { #[test] fn test_tokenize() { assert_eq!( - tokenize("test arg1 arg2 arg3"), - vec!["test", "arg1", "arg2", "arg3"] + tokenize("keyword arg1 arg2 arg3"), + vec!["keyword", "arg1", "arg2", "arg3"] ); } #[test] fn test_parse_line() { assert_eq!( - parse_line("test arg1 arg2 arg3"), - ("test", vec!["arg1", "arg2", "arg3"]) + parse_line("keyword arg1 arg2 arg3"), + ("keyword", vec!["arg1", "arg2", "arg3"]) ); } }