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]
impl<Ext> ShellOptions<Ext>
[src]pub fn with_current_dir(self, current_dir: impl AsRef<Path>) -> Self
[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]
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]
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]
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.
pub fn with_cargo_path(self) -> Self
[src]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]
impl ShellOptions<StdShell>
[src]pub fn powershell() -> Self
[src]
pub fn powershell() -> Self
[src]Creates options for PowerShell.
pub fn with_alias(self, name: &str, path_to_bin: &str) -> Self
[src]
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. Forsh
,name
must be a valid name for thealias
command. Thename
validity is not checked.
Trait Implementations
impl<Ext: Debug> Debug for ShellOptions<Ext>
[src]
impl<Ext: Debug> Debug for ShellOptions<Ext>
[src]impl Default for ShellOptions
[src]
impl Default for ShellOptions
[src]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,
Ext: Unpin,