[−][src]Function shellfn_core::execute_vec_result_nopanic
pub fn execute_vec_result_nopanic<T, TArg, TEnvKey, TEnvVal, TError>(
cmd: impl AsRef<OsStr>,
args: impl IntoIterator<Item = TArg>,
envs: impl IntoIterator<Item = (TEnvKey, TEnvVal)>
) -> Result<Vec<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>>,
Executes command with args and environment variables, parses output line by line, returns after reading whole output
- On invalid command: return error
- On error exit code: return error
- On parsing failure: skip item
- Possible errors: ProcessNotSpawned, WaitFailed, ProcessFailed
Designed for
use shellfn::shell; use std::error::Error; #[shell(no_panic)] fn command() -> Result<Vec<u32>, Box<Error>> { "echo 1; echo 2; echo 3" } assert_eq!(vec![1, 2, 3], command().unwrap().collect::<Vec<_>>())