Struct xshell::Cmd

source · []
pub struct Cmd<'a> { /* private fields */ }
Expand description

A builder object for constructing a subprocess.

A Cmd is usually created with the cmd! macro. The command exists within a context of a Shell and uses its working directory and environment.

Example

use xshell::{Shell, cmd};

let sh = Shell::new()?;

let branch = "main";
let cmd = cmd!(sh, "git switch {branch}").quiet().run()?;

Implementations

Adds an argument to this commands.

Adds all of the arguments to this command.

Overrides the value of the environmental variable for this command.

Overrides the values of specified environmental variables for this command.

Removes the environment variable from this command.

Removes all of the environment variables from this command.

Don’t return an error if command the command exits with non-zero status.

By default, non-zero exit status is considered an error.

Controls whether non-zero exit status is considered an error.

Don’t echo the command itself to stderr.

By default, the command itself will be printed to stderr when executed via Cmd::run.

Controls whether the command itself is printed to stderr.

Marks the command as secret.

If a command is secret, it echoes <secret> instead of the program and its arguments, even in error messages.

Controls whether the command is secret.

Pass the given slice to the standard input of the spawned process.

Ignores the standard output stream of the process.

This is equivalent to redirecting stdout to /dev/null. By default, the stdout is inherited or captured.

Controls whether the standard output is ignored.

Ignores the standard output stream of the process.

This is equivalent redirecting stderr to /dev/null. By default, the stderr is inherited or captured.

Controls whether the standard error is ignored.

Runs the command.

By default the command itself is echoed to stderr, its standard streams are inherited, and non-zero return code is considered an error. These behaviors can be overridden by using various builder methods of the Cmd.

Run the command and return its stdout as a string.

Run the command and return its stderr as a string.

Run the command and return its output.

Trait Implementations

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.