pub fn execute_iter_result_panic<T, TArg, TEnvKey, TEnvVal, TError>(
cmd: impl AsRef<OsStr>,
args: impl IntoIterator<Item = TArg>,
envs: impl IntoIterator<Item = (TEnvKey, TEnvVal)>,
) -> Result<impl Iterator<Item = T>, TError>Expand description
Executes command with args and environment variables, parses output line by line
- On invalid command: return error
- On error exit code: break iterator
- On parsing failure: panic
- Possible errors: ProcessNotSpawned
Designed for
use shellfn::shell;
use std::error::Error;
#[shell]
fn command() -> Result<impl Iterator<Item = u32>, Box<Error>> {
"echo 1; echo 2; echo 3"
}
assert_eq!(vec![1, 2, 3], command().unwrap().collect::<Vec<_>>())