Type Alias Command

Source
pub type Command<'s> = OwningCommand<&'s Session>;
Expand description

Convenience OwningCommand alias when working with a session reference.

Aliased Type§

struct Command<'s> { /* private fields */ }

Implementations

Source§

impl<S> OwningCommand<S>

Source

pub fn arg<A: AsRef<str>>(&mut self, arg: A) -> &mut Self

Adds an argument to pass to the remote program.

Before it is passed to the remote host, arg is escaped so that special characters aren’t evaluated by the remote shell. If you do not want this behavior, use raw_arg.

Only one argument can be passed per use. So instead of:

.arg("-C /path/to/repo")

usage would be:

.arg("-C")
.arg("/path/to/repo")

To pass multiple arguments see args.

Source

pub fn raw_arg<A: AsRef<OsStr>>(&mut self, arg: A) -> &mut Self

Adds an argument to pass to the remote program.

Unlike arg, this method does not shell-escape arg. The argument is passed as written to ssh, which will pass it again as an argument to the remote shell. Since the remote shell may do argument parsing, characters such as spaces and * may be interpreted by the remote shell.

To pass multiple unescaped arguments see raw_args.

Source

pub fn args<I, A>(&mut self, args: I) -> &mut Self
where I: IntoIterator<Item = A>, A: AsRef<str>,

Adds multiple arguments to pass to the remote program.

Before they are passed to the remote host, each argument in args is escaped so that special characters aren’t evaluated by the remote shell. If you do not want this behavior, use raw_args.

To pass a single argument see arg.

Source

pub fn raw_args<I, A>(&mut self, args: I) -> &mut Self
where I: IntoIterator<Item = A>, A: AsRef<OsStr>,

Adds multiple arguments to pass to the remote program.

Unlike args, this method does not shell-escape args. The arguments are passed as written to ssh, which will pass them again as arguments to the remote shell. However, since the remote shell may do argument parsing, characters such as spaces and * may be interpreted by the remote shell.

To pass a single argument see raw_arg.

Source

pub fn stdin<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Self

Configuration for the remote process’s standard input (stdin) handle.

Defaults to inherit when used with spawn or status, and defaults to null when used with output.

Source

pub fn stdout<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Self

Configuration for the remote process’s standard output (stdout) handle.

Defaults to inherit when used with spawn or status, and defaults to piped when used with output.

Source

pub fn stderr<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Self

Configuration for the remote process’s standard error (stderr) handle.

Defaults to inherit when used with spawn or status, and defaults to piped when used with output.

Source§

impl<S: Clone> OwningCommand<S>

Source

pub async fn spawn(&mut self) -> Result<Child<S>, Error>

Executes the remote command without waiting for it, returning a handle to it instead.

By default, stdin, stdout and stderr are inherited.

Source

pub async fn output(&mut self) -> Result<Output, Error>

Executes the remote command, waiting for it to finish and collecting all of its output.

By default, stdout and stderr are captured (and used to provide the resulting output) and stdin is set to Stdio::null().

Source

pub async fn status(&mut self) -> Result<ExitStatus, Error>

Executes the remote command, waiting for it to finish and collecting its exit status.

By default, stdin, stdout and stderr are inherited.

Trait Implementations

Source§

impl<S: Debug> Debug for OwningCommand<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more