From eca41e04dd8879592fba1a900342e817c3543555 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 13 May 2016 14:41:19 +0200 Subject: [PATCH] Add argument finder helper function --- bin/src/main.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bin/src/main.rs b/bin/src/main.rs index 925fb49f..3b154a47 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs @@ -98,6 +98,14 @@ fn find_command() -> Option { env::args().skip(1).filter(|x| !x.starts_with("-")).next() } +fn find_args(command: &str) -> Vec { + env::args() + .skip(1) + .position(|e| e == command) + .map(|pos| env::args().skip(pos + 2).collect::>()) + .unwrap_or(vec![]) +} + fn main() { let commands = get_commands(); let mut args = env::args(); @@ -145,6 +153,7 @@ fn main() { .stdin(Stdio::inherit()) .stdout(Stdio::inherit()) .stderr(Stdio::inherit()) + .args(&find_args(s)[..]) .spawn() .and_then(|mut handle| handle.wait()) {