execute_vec_panic_result

Function execute_vec_panic_result 

Source
pub fn execute_vec_panic_result<T, TArg, TEnvKey, TEnvVal, TError>(
    cmd: impl AsRef<OsStr>,
    args: impl IntoIterator<Item = TArg>,
    envs: impl IntoIterator<Item = (TEnvKey, TEnvVal)>,
) -> Vec<Result<T, TError>>
where T: FromStr, TArg: AsRef<OsStr>, TEnvKey: AsRef<OsStr>, TEnvVal: AsRef<OsStr>, <T as FromStr>::Err: StdError, TError: From<Error<<T as FromStr>::Err>>,
Expand description

Executes command with args and environment variables, parses output line by line, returns after reading whole output

  • On invalid command: panic
  • On error exit code: panic
  • On parsing failure: collect error item
  • Possible errors: StdoutUnreadable (item error), ParsingError (item error)

Designed for

use shellfn::shell;
use std::error::Error;

#[shell]
fn command() -> Vec<Result<u32, Box<Error + 'static>>> {
    "echo 1; echo 2; echo 3"
}

assert_eq!(vec![1, 2, 3], command().map(Result::unwrap).collect::<Vec<_>>())