Skip to main content

Module shell

Module shell 

Source
Expand description

The shell::Shell trait and its standard implementations. The Shell trait and its standard implementations.

§Overview

  • Shell — the core trait; implement it to control how processes are spawned.
  • ProcessShell — the production implementation; spawns real OS processes.
  • DryRunShell — logs what would be executed and returns fake success; safe to use in dry-run workflows.
  • MockShell — records calls and returns configurable results; intended for unit tests.
  • ScriptedShell — drives the real spinner overlay using pre-configured output scripts; intended for overlay integration tests.

Use create to get a boxed Shell at runtime based on a dry_run flag.

Modules§

scripted
Scripted shell for driving the spinner overlay in tests without spawning real OS processes.

Structs§

CommandResult
The outcome of a completed shell command.
DryRunShell
Dry-run shell: logs what would be executed and returns fake success. Probe methods (command_exists, command_output) delegate to real implementations because they are read-only and safe to call.
MockShell
Mock shell for unit tests: records calls and returns configurable results.
ProcessShell
Production shell: delegates to the free functions in this module.
ShellConfig
Configuration for shell execution behaviour.

Enums§

ShellError
Errors that can be returned by Shell methods.

Traits§

Shell
Abstraction over shell execution, enabling unit tests to mock process spawning.

Functions§

command_exists
Check if a program is on PATH. Uses which on unix, where.exe on windows.
command_output
Run a command and return its stdout (trimmed).
create
Returns a DryRunShell when dry_run is true, otherwise a ProcessShell. Both shells are configured with ShellConfig::default(). Use ProcessShell or DryRunShell directly if you need custom config.
run_command
Run a shell command with mode-appropriate output:
run_passthrough
Run a command with stdout and stderr inherited from the parent process.
shell_exec
Execute a script via the system shell. Unix: bash -c "script", Windows: powershell -Command "script".