heroforge-core 0.2.2

Pure Rust core library for reading and writing Fossil SCM repositories
Documentation
//! Rhai Scripting API for heroforge-core
//!
//! This module provides a complete Rhai scripting interface for Fossil repositories.
//! It enables scripting of repository operations, filesystem manipulation, and more.
//!
//! ## Architecture
//!
//! ```text
//! ┌─────────────────┐         Unix Socket          ┌─────────────────────┐
//! │ heroforge-core  │◄───────────────────────────►│ heroforge-core      │
//! │   (client)      │  ~/hero/var/heroforge.sock  │   (daemon)          │
//! └─────────────────┘                              └─────────────────────┘
//!         │                                                 │
//!         │ sends script                                    │ executes script
//!         │ receives streamed output                        │ via Rhai engine
//!         ▼                                                 ▼
//! ┌─────────────────┐                              ┌─────────────────────┐
//! │  script.rhai    │                              │   ForgeEngine       │
//! │  or stdin       │                              │   (Rhai + Forge API)│
//! └─────────────────┘                              └─────────────────────┘
//! ```
//!
//! ## Quick Start
//!
//! ```no_run
//! use heroforge_core::rhai_api::ForgeEngine;
//!
//! let engine = ForgeEngine::new()?;
//! let result = engine.eval::<i64>("1 + 2")?;
//! assert_eq!(result, 3);
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! ## Available Functions in Scripts
//!
//! ### Repository Operations
//! - `repo_open(path)` - Open repository read-only
//! - `repo_open_rw(path)` - Open repository read-write
//! - `repo_init(path)` - Create new repository
//!
//! ### Filesystem Operations
//! - `fs_new(repo, author)` - Create FsInterface for repository
//! - `fs_read(fs, path)` - Read file content as string
//! - `fs_read_bytes(fs, path)` - Read file content as bytes
//! - `fs_write(fs, path, content)` - Write file
//! - `fs_exists(fs, path)` - Check if path exists
//! - `fs_delete(fs, path)` - Delete file
//! - `fs_list(fs, dir)` - List directory contents
//! - `fs_commit(fs)` - Force commit staged changes
//!
//! ### File Operations (via Repository)
//! - `files_list(repo)` - List all files on trunk
//! - `files_list_branch(repo, branch)` - List files on branch
//! - `files_read(repo, path)` - Read file from trunk
//! - `files_find(repo, pattern)` - Find files matching pattern
//!
//! ### Branch/Tag Operations
//! - `branches_list(repo)` - List all branches
//! - `branches_create(repo, name, from_branch, author)` - Create branch
//! - `tags_list(repo)` - List all tags
//! - `tags_create(repo, name, at_branch, author)` - Create tag
//!
//! ### Commit Operations
//! - `commit(repo, message, author, files)` - Create commit
//!
//! ### Modify Operations
//! - `modify_new(repo)` - Create new Modify builder
//! - Various chainable methods for copy, move, delete, chmod

pub mod engine;
pub mod error;
pub mod socket_client;
pub mod socket_server;
pub mod types;

pub use engine::{ForgeEngine, clear_output_sender, set_output_sender};
pub use error::RhaiError;
pub use socket_client::SocketClient;
pub use socket_server::SocketServer;
pub use types::*;