- Update README.md to provide a clearer structure and improved installation instructions. This makes it easier for users to understand and use the library. - Remove outdated and unnecessary sections like the workspace structure details, publishing status, and detailed features lists. The information is either not relevant anymore or can be found elsewhere. - Simplify installation instructions to focus on the core aspects of installing individual packages or the meta-package with features. - Add a dedicated section for building and running tests, improving developer experience and making the process more transparent. - Modernize the overall layout and formatting for better readability.
149 lines
4.2 KiB
Markdown
149 lines
4.2 KiB
Markdown
# SAL (System Abstraction Layer)
|
|
|
|
**Version 0.1.0** - A modular Rust library for cross-platform system operations and automation.
|
|
|
|
SAL provides a unified interface for system operations with Rhai scripting support through the `herodo` tool.
|
|
|
|
## Installation
|
|
|
|
### Individual Packages (Recommended)
|
|
|
|
```bash
|
|
# Core functionality
|
|
cargo add sal-os sal-process sal-text sal-net
|
|
|
|
# Infrastructure
|
|
cargo add sal-git sal-vault sal-kubernetes sal-virt
|
|
|
|
# Database clients
|
|
cargo add sal-redisclient sal-postgresclient sal-zinit-client
|
|
|
|
# Scripting
|
|
cargo add sal-rhai
|
|
```
|
|
|
|
### Meta-package with Features
|
|
|
|
```bash
|
|
cargo add sal --features core # os, process, text, net
|
|
cargo add sal --features infrastructure # git, vault, kubernetes, virt
|
|
cargo add sal --features all # everything
|
|
```
|
|
|
|
### Herodo Script Runner
|
|
|
|
```bash
|
|
cargo install herodo
|
|
```
|
|
|
|
## Quick Start
|
|
|
|
### Rust Library Usage
|
|
|
|
```rust
|
|
use sal_os::fs;
|
|
use sal_process::run;
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
let files = fs::list_files(".")?;
|
|
println!("Found {} files", files.len());
|
|
|
|
let result = run::command("echo hello")?;
|
|
println!("Output: {}", result.stdout);
|
|
Ok(())
|
|
}
|
|
```
|
|
|
|
### Herodo Scripting
|
|
|
|
```bash
|
|
# Create script
|
|
cat > example.rhai << 'EOF'
|
|
let files = find_files(".", "*.rs");
|
|
print("Found " + files.len() + " Rust files");
|
|
|
|
let result = run("echo 'Hello from SAL!'");
|
|
print("Output: " + result.stdout);
|
|
EOF
|
|
|
|
# Run script
|
|
herodo example.rhai
|
|
```
|
|
|
|
## Available Packages
|
|
|
|
| Package | Description |
|
|
|---------|-------------|
|
|
| [`sal-os`](https://crates.io/crates/sal-os) | Operating system operations |
|
|
| [`sal-process`](https://crates.io/crates/sal-process) | Process management |
|
|
| [`sal-text`](https://crates.io/crates/sal-text) | Text processing |
|
|
| [`sal-net`](https://crates.io/crates/sal-net) | Network operations |
|
|
| [`sal-git`](https://crates.io/crates/sal-git) | Git repository management |
|
|
| [`sal-vault`](https://crates.io/crates/sal-vault) | Cryptographic operations |
|
|
| [`sal-kubernetes`](https://crates.io/crates/sal-kubernetes) | Kubernetes management |
|
|
| [`sal-virt`](https://crates.io/crates/sal-virt) | Virtualization tools |
|
|
| [`sal-redisclient`](https://crates.io/crates/sal-redisclient) | Redis client |
|
|
| [`sal-postgresclient`](https://crates.io/crates/sal-postgresclient) | PostgreSQL client |
|
|
| [`sal-zinit-client`](https://crates.io/crates/sal-zinit-client) | Zinit process supervisor |
|
|
| [`sal-mycelium`](https://crates.io/crates/sal-mycelium) | Mycelium network client |
|
|
| [`sal-service-manager`](https://crates.io/crates/sal-service-manager) | Service management |
|
|
| [`sal-rhai`](https://crates.io/crates/sal-rhai) | Rhai scripting integration |
|
|
| [`sal`](https://crates.io/crates/sal) | Meta-crate with features |
|
|
| [`herodo`](https://crates.io/crates/herodo) | Script executor binary |
|
|
|
|
## Building & Testing
|
|
|
|
```bash
|
|
# Build all packages
|
|
cargo build --workspace
|
|
|
|
# Run tests
|
|
cargo test --workspace
|
|
|
|
# Run Rhai integration tests
|
|
./run_rhai_tests.sh
|
|
```
|
|
|
|
## Core Features
|
|
|
|
- **System Operations**: File/directory management, environment access, OS commands
|
|
- **Process Management**: Create, monitor, and control system processes
|
|
- **Containerization**: Buildah and nerdctl integration
|
|
- **Version Control**: Git repository operations
|
|
- **Database Clients**: Redis and PostgreSQL support
|
|
- **Networking**: HTTP, TCP, SSH connectivity utilities
|
|
- **Cryptography**: Key management, encryption, digital signatures
|
|
- **Text Processing**: String manipulation and templating
|
|
- **Scripting**: Rhai script execution via `herodo`
|
|
|
|
## Herodo Scripting
|
|
|
|
`herodo` executes Rhai scripts with access to all SAL modules:
|
|
|
|
```bash
|
|
herodo script.rhai # Run single script
|
|
herodo script.rhai arg1 arg2 # With arguments
|
|
herodo /path/to/scripts/ # Run all .rhai files in directory
|
|
```
|
|
|
|
### Example Script
|
|
|
|
```rhai
|
|
// File operations
|
|
let files = find_files(".", "*.rs");
|
|
print("Found " + files.len() + " Rust files");
|
|
|
|
// Process execution
|
|
let result = run("echo 'Hello SAL!'");
|
|
print("Output: " + result.stdout);
|
|
|
|
// Redis operations
|
|
redis_set("status", "running");
|
|
let status = redis_get("status");
|
|
print("Status: " + status);
|
|
```
|
|
|
|
## License
|
|
|
|
Licensed under the Apache License 2.0. See [LICENSE](LICENSE) for details.
|