Struct term_transcript::ShellOptions[][src]

pub struct ShellOptions<Ext = ()> { /* fields omitted */ }
Expand description

Options for executing commands in the shell. Used in Transcript::from_inputs() and in TestConfig.

The type param maps to extensions available for the shell. For example, StdShell extension allows to specify custom aliases for the executed commands.

Implementations

impl<Ext> ShellOptions<Ext>[src]

pub fn with_current_dir(self, current_dir: impl AsRef<Path>) -> Self[src]

Changes the current directory of the command.

pub fn with_io_timeout(self, io_timeout: Duration) -> Self[src]

Sets the I/O timeout for shell commands. This determines how long methods like Transcript::from_inputs() wait for output of a command before proceeding to the next command. Longer values allow to capture output more accurately, but result in longer execution.

pub fn with_init_command(self, command: impl Into<String>) -> Self[src]

Adds an initialization command. Such commands are sent to the shell before executing any user input. The corresponding output from the shell is not captured.

pub fn with_line_mapper<F>(self, mapper: F) -> Self where
    F: FnMut(String) -> Option<String> + 'static, 
[src]

Sets the line mapper for the shell. This allows to filter and/or map terminal outputs.

pub fn with_cargo_path(self) -> Self[src]

This is supported on Unix or Windows only.

Adds paths to cargo binaries (including examples) to the PATH env variable. This allows to call them by the corresponding filename, without specifying a path or doing complex preparations (e.g., calling cargo install).

Limitations

  • The caller must be a unit or integration test; the method will work improperly otherwise.

impl ShellOptions<StdShell>[src]

pub fn sh() -> Self[src]

Creates options for an sh shell.

pub fn bash() -> Self[src]

Creates options for a Bash shell.

pub fn powershell() -> Self[src]

Creates options for PowerShell.

pub fn with_alias(self, name: &str, path_to_bin: &str) -> Self[src]

Creates an alias for the binary at path_to_bin, which should be an absolute path. This allows to call the binary using this alias without complex preparations (such as installing it globally via cargo install), and is more flexible than Self::with_cargo_path().

In integration tests, you may use env!("CARGO_BIN_EXE_<name>") to get a path to binary targets.

Limitations

  • For Bash and PowerShell, name must be a valid name of a function. For sh, name must be a valid name for the alias command. The name validity is not checked.

Trait Implementations

impl<Ext: Debug> Debug for ShellOptions<Ext>[src]

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Default for ShellOptions[src]

fn default() -> Self[src]

Returns the “default value” for a type. Read more

impl From<Command> for ShellOptions[src]

fn from(command: Command) -> Self[src]

Performs the conversion.

Auto Trait Implementations

impl<Ext = ()> !RefUnwindSafe for ShellOptions<Ext>

impl<Ext = ()> !Send for ShellOptions<Ext>

impl<Ext = ()> !Sync for ShellOptions<Ext>

impl<Ext> Unpin for ShellOptions<Ext> where
    Ext: Unpin

impl<Ext = ()> !UnwindSafe for ShellOptions<Ext>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.