You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
508 B
22 lines
508 B
use std::{
|
|
io::{self, Write},
|
|
process::Command,
|
|
};
|
|
|
|
pub fn parse_line(line: &str) -> io::Result<()> {
|
|
let tokens = line.trim().split(' ').collect::<Vec<&str>>();
|
|
let mut args: &[&str] = &[];
|
|
let command = tokens[0];
|
|
if !args.is_empty() {
|
|
args = &tokens[1..];
|
|
}
|
|
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(())
|
|
}
|