diff options
Diffstat (limited to 'src/command.rs')
-rw-r--r-- | src/command.rs | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/src/command.rs b/src/command.rs index b72d94e..cf01767 100644 --- a/src/command.rs +++ b/src/command.rs @@ -37,8 +37,9 @@ impl Command { }) } - pub fn pty(&self) -> &std::fs::File { - self.pty.pt() + pub fn arg<S: AsRef<std::ffi::OsStr>>(&mut self, arg: S) -> &mut Self { + self.command.arg(arg); + self } pub fn args<I, S>(&mut self, args: I) -> &mut Self @@ -50,9 +51,63 @@ impl Command { self } + pub fn env<K, V>(&mut self, key: K, val: V) -> &mut Self + where + K: AsRef<std::ffi::OsStr>, + V: AsRef<std::ffi::OsStr>, + { + self.command.env(key, val); + self + } + + pub fn envs<I, K, V>(&mut self, vars: I) -> &mut Self + where + I: IntoIterator<Item = (K, V)>, + K: AsRef<std::ffi::OsStr>, + V: AsRef<std::ffi::OsStr>, + { + self.command.envs(vars); + self + } + + pub fn env_remove<K: AsRef<std::ffi::OsStr>>( + &mut self, + key: K, + ) -> &mut Self { + self.command.env_remove(key); + self + } + + pub fn env_clear(&mut self) -> &mut Self { + self.command.env_clear(); + self + } + + pub fn current_dir<P: AsRef<std::path::Path>>( + &mut self, + dir: P, + ) -> &mut Self { + self.command.current_dir(dir); + self + } + + pub fn uid(&mut self, id: u32) -> &mut Self { + self.command.uid(id); + self + } + + pub fn gid(&mut self, id: u32) -> &mut Self { + self.command.gid(id); + self + } + pub fn spawn(&mut self) -> Result<std::process::Child> { let child = self.command.spawn()?; self.pts_fh = None; Ok(child) } + + pub fn pty(&self) -> &std::fs::File { + self.pty.pt() + } } |