run_script 0.1.4

Run shell scripts in rust.
Documentation

run_script

crates.io Build Status Build status codecov license Libraries.io for GitHub Documentation downloads Built with cargo-make

Run shell scripts in rust.

Overview

This library enables to invoke shell scripts based on their content. While std::process::Command works great to execute standalone command, you need more manual code to take a script text and execute it. For this purpose, this library was created.

Usage

Simply include the library and invoke the run function with the script text and run options:

extern crate run_script;

use run_script::ScriptOptions;

fn main() {
    let mut options = ScriptOptions::new();
    options.runner = None; // The script runner, for example bash. By default for windows it's cmd.exe and for other systems it is sh.
    options.capture_output = true; // True to capture and return the output. False will print it to the parent process output.
    options.exit_on_error = false; // Adds set -e option (not available for windows)
    options.print_commands = false; // Adds set -x option (not available for windows)

    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);
}

Installation

In order to use this library, just add it as a dependency:

[dependencies]
run_script = "*"

API Documentation

See full docs at: API Docs

Contributing

See contributing guide

Release History

Date Version Description
2017-11-04 v0.1.4 Initial release.

License

Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.