use crate::{BoxError, StandardOptions, SysexitsError::*};
use asimov_module::ModuleName;
use color_print::cprintln;
pub async fn enable(
module_names: Vec<ModuleName>,
flags: &StandardOptions,
) -> Result<(), BoxError> {
let registry = asimov_registry::Registry::default();
for module_name in module_names {
if flags.verbose > 1 {
cprintln!("<s,c>»</> Enabling module <s>{module_name}</>...");
}
registry.enable_module(&module_name).await.map_err(|e| {
tracing::error!("failed to enable module `{module_name}`: {e}");
EX_UNAVAILABLE
})?;
if flags.verbose > 0 {
cprintln!("<s,g>✓</> Enabled module <s>{module_name}</>.");
}
}
Ok(())
}