OpenRunner-RS
OpenRunner-RS is a powerful, async-first Rust library for executing OpenScript code and shell scripts with fine-grained control over execution environment, I/O redirection, process lifecycle, and error handling.
Features
- Async-First Design: Built on tokio for high-performance concurrent execution
- Flexible Script Sources: Execute from strings, files, or remote sources
- Fine-Grained Control: Full control over environment variables, working directory, I/O redirection
- Process Management: Spawn long-running processes with full lifecycle control
- Timeout Support: Built-in timeout handling with graceful process termination
- Error Handling: Comprehensive error types with detailed context
- Convenience Macros: Ergonomic macros for common use cases
- Zero-Copy I/O: Efficient handling of large script outputs
- Cross-Platform: Works on Linux, macOS, and Windows
Installation
Add to your Cargo.toml:
[]
= "1.0"
= { = "1", = ["full"] }
Quick Start
Basic Script Execution
use ;
async
Advanced Configuration
use ;
use Duration;
async
Process Spawning
use ;
async
API Reference
Core Functions
| Function | Description |
|---|---|
run(script, options) |
Execute script and wait for completion |
run_file(path, options) |
Execute script from file |
spawn(script, options) |
Spawn script process without waiting |
spawn_file(path, options) |
Spawn script from file |
Convenience Macros
| Macro | Description |
|---|---|
run_script!(script, options?) |
Simplified script execution |
spawn_script!(script, options?) |
Simplified script spawning |
run_file_script!(path, options?) |
Simplified file execution |
Configuration Options
new
.openscript_path // Script interpreter
.working_directory // Working directory
.env // Environment variables
.args // Command arguments
.timeout // Execution timeout
.stdin // Stdin handling
.stdout // Stdout handling
.stderr // Stderr handling
.clear_env // Clear environment
.exit_on_error // Continue on errors
.print_commands // Debug output
Examples
File Execution
use ;
use PathBuf;
async
Error Handling
use ;
async
Using Macros
use ;
async
Testing
Run the test suite:
# Run all tests
# Run with output
# Run integration tests only
# Run with coverage
Docker Support
Build and test in Docker:
# Build the container
# Run tests in container
# Run examples
Benchmarks
Run performance benchmarks:
# Run all benchmarks
# Run specific benchmark
# Generate benchmark report
Cross-Platform Support
OpenRunner-RS works across platforms:
- Linux: Full support with all features
- macOS: Full support with all features
- Windows: Full support with PowerShell and cmd.exe
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Development Setup
# Clone the repository
# Install development dependencies
# Run tests with file watching
# Check code quality
Changelog
See CHANGELOG.md for version history and breaking changes.
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.