pub struct CommandBuilder { /* private fields */ }Expand description
Builder wrapper that centralizes direct usages of std::process::Command.
Implementations§
Source§impl CommandBuilder
impl CommandBuilder
pub fn new(program: impl AsRef<OsStr>) -> Self
pub fn arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self
pub fn args<S, I>(&mut self, args: I) -> &mut Self
pub fn env( &mut self, key: impl AsRef<OsStr>, value: impl AsRef<OsStr>, ) -> &mut Self
pub fn env_remove(&mut self, key: impl AsRef<OsStr>) -> &mut Self
Sourcepub fn env_clear(&mut self) -> &mut Self
pub fn env_clear(&mut self) -> &mut Self
Clear the inherited host environment, so staged script env is the
whole child env. Mirrors std::process::Command::env_clear while
keeping the snapshot consistent for diagnostics.
pub fn stdin_file(&mut self, file: File) -> &mut Self
pub fn stdin_piped(&mut self) -> &mut Self
pub fn stdout_piped(&mut self) -> &mut Self
pub fn stderr_piped(&mut self) -> &mut Self
pub fn current_dir(&mut self, dir: impl AsRef<Path>) -> &mut Self
pub fn status(&mut self) -> Result<ExitStatus>
pub fn output(&mut self) -> Result<CommandOutput>
pub fn spawn(&mut self) -> Result<ChildHandle>
Sourcepub fn spawn_piped(&mut self) -> Result<PipedChild>
pub fn spawn_piped(&mut self) -> Result<PipedChild>
Spawn with piped stdio halves handed back for frame pumps: stdin and
stdout are forced to pipes (stderr keeps whatever was configured,
usually inherited for diagnostics). The remaining child is wrapped
in a ChildHandle so kill-on-drop and reaping behave identically
to spawn. Sessions own the halves and join their
pump threads; dropping the halves closes the pipes.
Sourcepub fn spawn_piped_with_stderr(&mut self) -> Result<PipedChild>
pub fn spawn_piped_with_stderr(&mut self) -> Result<PipedChild>
Like spawn_piped, but stderr is also piped
and handed back: binary-safe sessions keep diagnostics off stdout
and route them to their own pipe. Dropping the half closes it.
Sourcepub fn snapshot(&self) -> CommandSnapshot
pub fn snapshot(&self) -> CommandSnapshot
Return a lightweight snapshot of the command configuration for testing.