pub fn run_with_stdin<F, E>(cmd: &str, f: F) -> Result<Output, E> where
    F: FnOnce(&mut ChildStdin) -> Result<(), E>,
    E: From<Error>, 
Expand description

Runs command with access to it’s stdin.

Spawns the given command then run it’s piped stdin through the given closure. The closure’s Result Error type is used as the function’s result so the users can use their locally defined error types and Error itself can also be used.

Examples

let output = easy_process::run_with_stdin("rev", |stdin| {
    std::io::Write::write_all(stdin, b"Hello, world!")?;
    easy_process::Result::Ok(())
})?;
assert_eq!("!dlrow ,olleH", &output.stdout);