herolib-core
Core utilities including text processing, networking, and the HeroScript configuration language.
Documentation
Interactive Shell (hero-core)
herolib-core includes hero-core, an interactive Rhai shell with full readline support:
# Install the shell
# Or run directly after building
Features:
- Tab completion for all functions
- Syntax highlighting for Rhai code
- Command history (Up/Down arrows)
- Function signature hints
- Multi-line input support
Shell commands:
/help- Show help/functions- List all available functions/text- Show text module functions/net- Show network functions/heroscript- Show HeroScript functions/scope- Show current variables/load <file>- Load and execute a .rhai script/quit- Exit (or Ctrl+D)
Installation
Or add to your Cargo.toml:
[]
= "0.1"
Building
Modules
heroscript
A defensive configuration and scripting language designed for safe, predictable system orchestration.
- Parse and execute HeroScript configuration files
- Type-safe parameter handling
- Wildcard action filtering
- Struct serialization with derive macros (
ToHeroScript,FromHeroScript) - Source tracking and write-back support
- Include system for modular scripts
use ;
let script = "!!server.define name:web1 host:localhost port:8080";
let playbook = new?;
let action = playbook.get?;
let name = action.params.get?;
let port = action.params.get_u16?;
text
Text processing and manipulation utilities.
dedent/prefix- Text indentation handlingname_fix/path_fix- String sanitization for filenamesTextReplacer- Regex and literal text replacement with chainingTemplateBuilder- Tera-based template rendering
use ;
let clean = dedent;
let safe = name_fix; // "hello_world_.txt"
let replacer = builder
.pattern
.replacement
.regex
.build?;
let result = replacer.replace;
net
Network connectivity utilities.
- TCP port checking
- HTTP endpoint validation
- SSH connectivity testing
use net;
let is_up = tcp_check;
Rhai Integration
All modules are available in Rhai scripts (requires rhai v1.23.6).
// HeroScript
let pb = playbook_from_text("!!server.define name:web1 port:8080");
let server = pb.get("server.define");
print(server.get("name"));
// Text
let safe = name_fix("My File.txt");
let clean = dedent(" indented text");
// Replacer
let replacer = text_replacer_new()
.pattern("old")
.replacement("new")
.build();
let result = replacer.replace("old text");
Related Packages
| Package | Description |
|---|---|
herolib-derive |
Derive macros (ToHeroScript, FromHeroScript, ToSchema) |
License
Apache-2.0