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
# Interactive development
๐ง Development
Prerequisites
- Rust 1.70+
- tokio runtime
- Shell interpreter (bash, sh, etc.)
Building
# Debug build
# Release build
# Run examples
# Generate documentation
Linting
# Format code
# Run clippy
# Full lint check
๐ License
This project is dual-licensed under either:
at your option.
๐ค Contributing
Contributions are welcome! Please read our Contributing Guide for details on our development process, how to propose bugfixes and improvements.
๐ Support
- ๐ Documentation
- ๐ Issue Tracker
- ๐ฌ Discussions