Function run_script::run

source ·
pub fn run(
    script: &str,
    args: &Vec<String>,
    options: &ScriptOptions
) -> ScriptResult<(i32, String, String)>
Expand description

Invokes the provided script content and returns the invocation output.

Arguments

  • script - The script content
  • args - The script command line arguments
  • options - Options provided to the script runner

Example

use run_script::ScriptOptions;

fn main() {
    let options = ScriptOptions::new();

    let args = vec![];

    let (code, output, error) = run_script::run(
        r#"
        echo "Directory Info:"
        dir
        "#,
        &args,
        &options
    ).unwrap();

    println!("Exit Code: {}", code);
    println!("Output: {}", output);
    println!("Error: {}", error);
}