pub trait Shell {
// Required methods
fn run_command(
&self,
label: &str,
program: &str,
args: &[&str],
output: &mut dyn Output,
mode: OutputMode,
) -> Result<CommandResult, ShellError>;
fn shell_exec(
&self,
script: &str,
output: &mut dyn Output,
mode: OutputMode,
) -> Result<CommandResult, ShellError>;
fn command_exists(&self, program: &str) -> bool;
fn command_output(
&self,
program: &str,
args: &[&str],
) -> Result<String, ShellError>;
fn exec_capture(
&self,
cmd: &str,
output: &mut dyn Output,
mode: OutputMode,
) -> Result<CommandResult, ShellError>;
fn exec_interactive(
&self,
cmd: &str,
output: &mut dyn Output,
mode: OutputMode,
) -> Result<(), ShellError>;
}Expand description
Abstraction over shell execution, enabling unit tests to mock process spawning.
Required Methods§
Sourcefn run_command(
&self,
label: &str,
program: &str,
args: &[&str],
output: &mut dyn Output,
mode: OutputMode,
) -> Result<CommandResult, ShellError>
fn run_command( &self, label: &str, program: &str, args: &[&str], output: &mut dyn Output, mode: OutputMode, ) -> Result<CommandResult, ShellError>
Run program with args, displaying progress under label.
Output behavior is controlled by mode:
- quiet: output is collected silently.
- verbose: each line is echoed with a
>prefix. - default: an animated spinner overlay is shown.
Sourcefn shell_exec(
&self,
script: &str,
output: &mut dyn Output,
mode: OutputMode,
) -> Result<CommandResult, ShellError>
fn shell_exec( &self, script: &str, output: &mut dyn Output, mode: OutputMode, ) -> Result<CommandResult, ShellError>
Run an arbitrary shell script string (passed to bash -c / powershell -Command).
Sourcefn command_exists(&self, program: &str) -> bool
fn command_exists(&self, program: &str) -> bool
Return true when program can be found on PATH.
Sourcefn command_output(
&self,
program: &str,
args: &[&str],
) -> Result<String, ShellError>
fn command_output( &self, program: &str, args: &[&str], ) -> Result<String, ShellError>
Run program args and return its captured stdout as a trimmed String.
Sourcefn exec_capture(
&self,
cmd: &str,
output: &mut dyn Output,
mode: OutputMode,
) -> Result<CommandResult, ShellError>
fn exec_capture( &self, cmd: &str, output: &mut dyn Output, mode: OutputMode, ) -> Result<CommandResult, ShellError>
Run a shell command, capturing stdout/stderr silently without display.
In dry-run mode (DryRunShell), logs the command and returns success without executing.
Sourcefn exec_interactive(
&self,
cmd: &str,
output: &mut dyn Output,
mode: OutputMode,
) -> Result<(), ShellError>
fn exec_interactive( &self, cmd: &str, output: &mut dyn Output, mode: OutputMode, ) -> Result<(), ShellError>
Run a shell command with inherited stdio (for interactive flows like aws sso login).
In dry-run mode (DryRunShell), logs the command and returns success without executing.