//! Rhai integration for the virt package
//!
//! This module provides Rhai wrappers for virtualization and containerization functions,
//! enabling scripting access to Buildah, Nerdctl, QCOW2, Cloud Hypervisor, and Kubernetes operations.

pub mod buildah;
pub mod cloudhv;
pub mod nerdctl;
pub mod qcow2;

// Kubernetes Rhai integration - use the modular implementation in kubernetes/mod.rs
#[cfg(feature = "kubernetes")]
pub mod kubernetes;

use rhai::{Engine, EvalAltResult};

// Re-export the individual module registration functions
pub use buildah::register_bah_module;
pub use buildah::{Bah, bah_fluent_new_with_executor};
pub use cloudhv::register_cloudhv_module;
pub use nerdctl::register_nerdctl_module;
pub use qcow2::register_qcow2_module;


#[cfg(feature = "kubernetes")]
pub use kubernetes::register_kubernetes_module;

/// Register all virt module functions with the Rhai engine
///
/// This is a convenience function that registers all available virtualization modules
/// at once.
///
/// # Arguments
///
/// * `engine` - The Rhai engine to register the functions with
///
/// # Returns
///
/// * `Result<(), Box<EvalAltResult>>` - Ok if registration was successful, Err otherwise
pub fn register_virt_module(engine: &mut Engine) -> Result<(), Box<EvalAltResult>> {
    register_bah_module(engine)?;
    register_nerdctl_module(engine)?;
    register_qcow2_module(engine)?;
    register_cloudhv_module(engine)?;

    #[cfg(feature = "kubernetes")]
    register_kubernetes_module(engine)?;

    Ok(())
}
