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

  1. use std::{
  2. io::{self, Write},
  3. process::Command,
  4. };
  5. pub fn parse_line(line: &str) -> io::Result<()> {
  6. let tokens = line.trim().split(' ').collect::<Vec<&str>>();
  7. let mut args: &[&str] = &[];
  8. let command = tokens[0];
  9. if !args.is_empty() {
  10. args = &tokens[1..];
  11. }
  12. let mut command = Command::new(command);
  13. command.args(args);
  14. let output = command.output()?;
  15. io::stderr().write_all(&output.stderr)?;
  16. io::stdout().write_all(&output.stdout)?;
  17. Ok(())
  18. }