use crate::common::app_context::AppContext;
use crate::http_client::MantaClient;
use crate::output::action_result;
pub struct ExecParams<'a> {
pub target_group: &'a str,
pub parent_group: &'a str,
pub pattern: &'a str,
pub dry_run: bool,
pub create_group: bool,
pub output: Option<&'a str>,
}
pub async fn exec(
ctx: &AppContext<'_>,
shasta_token: &str,
p: ExecParams<'_>,
) -> anyhow::Result<()> {
let result = MantaClient::from_app_ctx(ctx)?
.add_hw_component(
shasta_token,
p.target_group,
p.parent_group,
p.pattern,
p.create_group,
p.dry_run,
)
.await?;
let message = if p.dry_run {
"Dryrun enabled, not modifying the groups on the system."
} else {
"Hardware components added."
};
action_result::print_with_data(message, &result, p.output)?;
Ok(())
}