//! Rhai scripting integration for the SAL library //! //! This module provides integration with the Rhai scripting language, //! allowing SAL functions to be called from Rhai scripts. mod error; mod os; mod process; mod buildah; mod nerdctl; mod git; #[cfg(test)] mod tests; // Re-export common Rhai types for convenience pub use rhai::{Array, Dynamic, Map, EvalAltResult, Engine}; // Re-export error module pub use error::*; // Re-export specific functions from modules to avoid name conflicts pub use os::{ register_os_module, // File system functions exist, find_file, find_files, find_dir, find_dirs, delete, mkdir, file_size, rsync, // Download functions download, download_install }; pub use process::{ register_process_module, // Run functions run, run_silent, run_with_options, new_run_options, // Process management functions which, kill, process_list, process_get }; // Re-export buildah functions pub use buildah::register_bah_module; pub use buildah::{ bah_from, bah_run, bah_run_with_isolation, bah_copy, bah_add, bah_commit, bah_remove, bah_list, bah_build_with_options, new_commit_options, new_config_options, image_commit_with_options, config_with_options }; // Re-export nerdctl functions pub use nerdctl::register_nerdctl_module; pub use nerdctl::{ nerdctl_run, nerdctl_exec, nerdctl_copy, nerdctl_stop, nerdctl_remove, nerdctl_list }; // Re-export git functions pub use git::register_git_module; pub use git::{ git_clone, git_list, git_update, git_update_force, git_update_commit, git_update_commit_push, has_git_changes, find_matching_repos }; // Rename copy functions to avoid conflicts pub use os::copy as os_copy; /// Register all SAL modules with the Rhai engine /// /// # Arguments /// /// * `engine` - The Rhai engine to register the modules with /// /// # Example /// /// ``` /// use rhai::Engine; /// use sal::rhai; /// /// let mut engine = Engine::new(); /// rhai::register(&mut engine); /// /// // Now you can use SAL functions in Rhai scripts /// let result = engine.eval::("exist('some_file.txt')").unwrap(); /// ``` pub fn register(engine: &mut Engine) -> Result<(), Box> { // Register OS module functions os::register_os_module(engine)?; // Register Process module functions process::register_process_module(engine)?; // Register Buildah module functions buildah::register_bah_module(engine)?; // Register Nerdctl module functions nerdctl::register_nerdctl_module(engine)?; // Register Git module functions git::register_git_module(engine)?; // Future modules can be registered here Ok(()) }