Function exec_target::exec_target_with_env_in [−][src]
pub fn exec_target_with_env_in<I, S, IKV, K, V>(
target_exe: &str,
args: I,
env: IKV,
in_bytes: &[u8]
) -> OutputString where
I: IntoIterator<Item = S>,
S: AsRef<OsStr>,
IKV: IntoIterator<Item = (K, V)>,
K: AsRef<OsStr>,
V: AsRef<OsStr>,
Expand description
This invokes external a command and manipulates standard in out.
You can use std::process::Command
more easily.
Example:
use exec_target::exec_target_with_env_in; let command = "target/debug/exe-stab-grep"; let args = &["--color=always", "-e", "c"]; let envs = vec![("GREP_COLORS", "ms=01;32")]; let inp = b"abcdefg\n" as &[u8]; let oup = exec_target_with_env_in(command, args, envs, inp); assert_eq!(oup.stderr, ""); assert_eq!(oup.stdout, "ab\u{1b}[01;32m\u{1b}[Kc\u{1b}[m\u{1b}[Kdefg\n"); assert_eq!(oup.status.success(), true);