From 09ff545fe44242734d5f6daf4a74946d2f04728d Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 30 Dec 2021 23:14:55 -0500 Subject: docs --- src/command.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/command.rs') diff --git a/src/command.rs b/src/command.rs index 00b51e7..8627a35 100644 --- a/src/command.rs +++ b/src/command.rs @@ -1,5 +1,6 @@ use async_process::unix::CommandExt as _; +/// Wrapper around [`async_process::Command`] pub struct Command { inner: async_process::Command, stdin: bool, @@ -12,6 +13,7 @@ pub struct Command { } impl Command { + /// See [`async_process::Command::new`] pub fn new>(program: S) -> Self { Self { inner: async_process::Command::new(program), @@ -23,11 +25,13 @@ impl Command { } } + /// See [`async_process::Command::arg`] pub fn arg>(&mut self, arg: S) -> &mut Self { self.inner.arg(arg); self } + /// See [`async_process::Command::args`] pub fn args(&mut self, args: I) -> &mut Self where I: IntoIterator, @@ -37,6 +41,7 @@ impl Command { self } + /// See [`async_process::Command::env`] pub fn env(&mut self, key: K, val: V) -> &mut Self where K: AsRef, @@ -46,6 +51,7 @@ impl Command { self } + /// See [`async_process::Command::envs`] pub fn envs(&mut self, vars: I) -> &mut Self where I: IntoIterator, @@ -56,6 +62,7 @@ impl Command { self } + /// See [`async_process::Command::env_remove`] pub fn env_remove>( &mut self, key: K, @@ -64,11 +71,13 @@ impl Command { self } + /// See [`async_process::Command::env_clear`] pub fn env_clear(&mut self) -> &mut Self { self.inner.env_clear(); self } + /// See [`async_process::Command::current_dir`] pub fn current_dir>( &mut self, dir: P, @@ -77,6 +86,7 @@ impl Command { self } + /// See [`async_process::Command::stdin`] pub fn stdin>( &mut self, cfg: T, @@ -86,6 +96,7 @@ impl Command { self } + /// See [`async_process::Command::stdout`] pub fn stdout>( &mut self, cfg: T, @@ -95,6 +106,7 @@ impl Command { self } + /// See [`async_process::Command::stderr`] pub fn stderr>( &mut self, cfg: T, @@ -104,6 +116,22 @@ impl Command { self } + /// Executes the command as a child process via + /// [`async_process::Command::spawn`], and attaches the given `pty` to + /// that child. The pty will be attached to all of `stdin`, `stdout`, and + /// `stderr` of the child, unless those file descriptors were previously + /// overridden through calls to [`stdin`](Self::stdin), + /// [`stdout`](Self::stdout), or [`stderr`](Self::stderr). The newly + /// created child process will also be made the session leader of a new + /// session, and will have the given `pty` instance set as its controlling + /// terminal. + /// + /// # Errors + /// Returns an error if we fail to allocate new file descriptors for + /// attaching the pty to the child process, or if we fail to spawn the + /// child process (see the documentation for + /// [`async_process::Command::spawn`]), or if we fail to make the child a + /// session leader or set its controlling terminal. pub fn spawn( &mut self, pty: &crate::Pty, @@ -140,16 +168,20 @@ impl Command { Ok(self.inner.spawn()?) } + /// See [`async_process::unix::CommandExt::uid`] pub fn uid(&mut self, id: u32) -> &mut Self { self.inner.uid(id); self } + /// See [`async_process::unix::CommandExt::gid`] pub fn gid(&mut self, id: u32) -> &mut Self { self.inner.gid(id); self } + /// See [`async_process::unix::CommandExt::pre_exec`] + #[allow(clippy::missing_safety_doc)] pub unsafe fn pre_exec(&mut self, f: F) -> &mut Self where F: FnMut() -> std::io::Result<()> + Send + Sync + 'static, @@ -158,6 +190,7 @@ impl Command { self } + /// See [`async_process::unix::CommandExt::arg0`] pub fn arg0(&mut self, arg: S) -> &mut Self where S: AsRef, -- cgit v1.2.3-54-g00ecf