| Crates.io | herolib-core |
| lib.rs | herolib-core |
| version | 0.3.13 |
| created_at | 2025-12-18 06:31:07.712554+00 |
| updated_at | 2026-01-24 05:23:57.031896+00 |
| description | Core utilities including text processing, networking, and HeroScript configuration language |
| homepage | |
| repository | https://forge.ourworld.tf/lhumina_code/herolib |
| max_upload_size | |
| id | 1991809 |
| size | 1,088,578 |
Core utilities including text processing, networking, and the HeroScript configuration language.
herolib-core includes hero-core, an interactive Rhai shell with full readline support:
# Install the shell
./install.sh
# Or run directly after building
./build.sh
./target/release/hero-core
Features:
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)cargo add herolib-core
Or add to your Cargo.toml:
[dependencies]
herolib-core = "0.1"
./build.sh
A defensive configuration and scripting language designed for safe, predictable system orchestration.
ToHeroScript, FromHeroScript)use herolib_core::heroscript::{PlayBook, PlayBookNewArgs, FindArgs};
let script = "!!server.define name:web1 host:localhost port:8080";
let playbook = PlayBook::new(PlayBookNewArgs {
text: script.to_string(),
..Default::default()
})?;
let action = playbook.get("server.define")?;
let name = action.params.get("name")?;
let port = action.params.get_u16("port")?;
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 renderinguse herolib_core::text::{dedent, name_fix, TextReplacer};
let clean = dedent(" indented
text");
let safe = name_fix("Hello World!.txt"); // "hello_world_.txt"
let replacer = TextReplacer::builder()
.pattern(r"\d+")
.replacement("NUM")
.regex(true)
.build()?;
let result = replacer.replace("42 items");
Network connectivity utilities.
use herolib_core::net;
let is_up = net::tcp_check("localhost", 8080);
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");
| Package | Description |
|---|---|
herolib-derive |
Derive macros (ToHeroScript, FromHeroScript, ToSchema) |
Apache-2.0