Skip to main content

Crate bare_script

Crate bare_script 

Source
Expand description

bare-script: The type-safe scripting authority for Rust.

A framework for building robust shell commands and automation with “Parse, don’t validate” philosophy.

§Overview

This library provides two APIs:

  • Sync API (sync::CommandBuilder): Uses std::process::Command
  • Async API (proc::CommandBuilder): Uses tokio::process::Command

§Quick Start - Sync

use bare_script::sync::CommandBuilder;

#[cfg(not(windows))]
{
let output = CommandBuilder::new("echo")
    .arg("Hello, world!")
    .capture_output()
    .execute();

assert!(output.is_ok());
assert!(output.unwrap().success());
}

§Quick Start - Async

use bare_script::proc::CommandBuilder;

#[tokio::main]
async fn main() -> Result<(), bare_script::ScriptError> {
    #[cfg(not(windows))]
    {
    let output = CommandBuilder::new("echo")
        .arg("Hello, world!")
        .capture_output()
        .execute()
        .await;

    assert!(output.is_ok());
    assert!(output.unwrap().success());
    }
    Ok(())
}

Re-exports§

pub use args::Arg;
pub use args::ArgType;
pub use args::Args;
pub use config::Config;
pub use config::StdioConfig;
pub use error::ScriptError;
pub use error::ScriptResult;
pub use output::Output;
pub use proc::CommandBuilder as AsyncCommandBuilder;
pub use sync::CommandBuilder;
pub use sync::Pipeline;
pub use proc::Pipeline as AsyncPipeline;

Modules§

args
Type-safe argument building for commands.
config
Configuration for command execution.
error
Error types for script command operations.
logging
Logging support for bare-script.
output
Command output types.
proc
Asynchronous command execution.
shell
Shell integration helpers.
sync
Synchronous command execution.