diff options
author | Jesse Luehrs <doy@tozt.net> | 2020-07-16 02:22:47 -0400 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2020-07-16 02:25:24 -0400 |
commit | b5497aa57978aa977de2848617a6d73ab2ee39ff (patch) | |
tree | 65d73346c0a2ad42fe8254efba6c4bf512b6b3a8 /src/command.rs | |
parent | be4eaa0f1972f8c8ab59a956c19c177cdd36479c (diff) | |
download | pty-process-b5497aa57978aa977de2848617a6d73ab2ee39ff.tar.gz pty-process-b5497aa57978aa977de2848617a6d73ab2ee39ff.zip |
add the rest of the command builder api that we care about
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() + } } |