Skip to main content

CommandExecutor

Trait CommandExecutor 

Source
pub trait CommandExecutor: Send + Sync {
    // Required methods
    fn execute(&self, program: &str, args: &[&str]) -> Result<CommandOutput>;
    fn execute_in_dir(
        &self,
        program: &str,
        args: &[&str],
        dir: &str,
    ) -> Result<CommandOutput>;
}
Expand description

Trait for executing shell commands

This abstraction allows mocking command execution in tests.

Required Methods§

Source

fn execute(&self, program: &str, args: &[&str]) -> Result<CommandOutput>

Execute a command and return its output

Source

fn execute_in_dir( &self, program: &str, args: &[&str], dir: &str, ) -> Result<CommandOutput>

Execute a command in a specific directory

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§