|
|
@ -1,22 +1,9 @@ |
|
|
|
use std::{
|
|
|
|
io::{self, Write},
|
|
|
|
process::Command,
|
|
|
|
};
|
|
|
|
|
|
|
|
pub fn parse_line(line: &str) -> io::Result<()> {
|
|
|
|
pub fn parse_line(line: &str) -> (&str, Vec<&str>) {
|
|
|
|
let tokens = line.trim().split(' ').collect::<Vec<&str>>();
|
|
|
|
let mut args: &[&str] = &[];
|
|
|
|
let mut args: Vec<&str> = Vec::new();
|
|
|
|
let command = tokens[0];
|
|
|
|
if tokens.len() > 1 {
|
|
|
|
args = &tokens[1..];
|
|
|
|
args = tokens[1..].to_vec();
|
|
|
|
}
|
|
|
|
let mut command = Command::new(command);
|
|
|
|
|
|
|
|
command.args(args);
|
|
|
|
|
|
|
|
let output = command.output()?;
|
|
|
|
|
|
|
|
io::stderr().write_all(&output.stderr)?;
|
|
|
|
io::stdout().write_all(&output.stdout)?;
|
|
|
|
Ok(())
|
|
|
|
(command, args)
|
|
|
|
}
|