From b5497aa57978aa977de2848617a6d73ab2ee39ff Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 16 Jul 2020 02:22:47 -0400 Subject: add the rest of the command builder api that we care about --- src/command.rs | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) (limited to 'src') 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>(&mut self, arg: S) -> &mut Self { + self.command.arg(arg); + self } pub fn args(&mut self, args: I) -> &mut Self @@ -50,9 +51,63 @@ impl Command { self } + pub fn env(&mut self, key: K, val: V) -> &mut Self + where + K: AsRef, + V: AsRef, + { + self.command.env(key, val); + self + } + + pub fn envs(&mut self, vars: I) -> &mut Self + where + I: IntoIterator, + K: AsRef, + V: AsRef, + { + self.command.envs(vars); + self + } + + pub fn env_remove>( + &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>( + &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 { let child = self.command.spawn()?; self.pts_fh = None; Ok(child) } + + pub fn pty(&self) -> &std::fs::File { + self.pty.pt() + } } -- cgit v1.2.3-54-g00ecf