1 unstable release
Uses new Rust 2024
| new 0.1.0 | Feb 9, 2026 |
|---|
#54 in #script
7KB
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
bare-script provides a type-safe approach to building shell commands and automation scripts in Rust:
- Type-safe commands - Strongly typed command arguments and options
- Validation at boundaries - Parse and validate input once, then trust throughout execution
- Cross-platform - Works consistently across Linux, macOS, and Windows
- Composable - Build complex pipelines from simple commands
- Zero runtime overhead - After validation, command execution is cost-free
Philosophy
Parse, Don't Validate
Traditional shell scripting relies on loose string manipulation and runtime checks. bare-script enforces:
- Parse - Convert command-line input into strongly typed values
- Validate - Ensure values meet constraints at command invocation
- Trust - Use validated values without re-checking during execution
This eliminates common shell scripting pitfalls and ensures type safety.
Quick Start
use bare_script::{Command, CommandBuilder};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let output = CommandBuilder::new("ls")
.arg("-l")
.arg("-h")
.build()?
.execute()?;
println!("{}", output);
eprintln!("{}", output.stderr);
Ok(())
}
Features
- Type-safe command building - Compile-time guarantee of valid command structure
- Cross-platform execution - Consistent behavior across operating systems
- Pipeline support - Chain commands together with pipes
- Output capture - Capture stdout, stderr, and exit codes
- Environment control - Set and manage environment variables
- Working directory management - Execute commands in specific directories
Roadmap
- Core command execution framework
- Type-safe argument parsing
- Pipeline and redirection support
- Cross-platform compatibility layer
- Environment variable management
- Output streaming
- Background process management
- Shell integration helpers
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT License (LICENSE-MIT)
Contributing
Contributions are welcome! Please open an issue or submit a PR.
Related Crates
- bare-types - Zero-cost foundation for type-safe domain modeling
- bare-config - Type-safe configuration authority