xbp 10.17.2

XBP is a zero-config build pack that can also interact with proxies, kafka, sockets, synthetic monitors.
Documentation
use crate::cli::commands;
use crate::cli::error::{CliResult, ErrorFactory};
use crate::cli::ui;
use crate::commands::install_api_service;
use crate::logging::{log_error, log_success};

pub async fn handle_api(cmd: commands::ApiCmd, debug: bool) -> CliResult<()> {
    match cmd.command {
        commands::ApiSubCommand::Install { port } => {
            if let Err(e) = ui::with_loader(
                &format!("Installing xbp-api.service on port {}", port),
                install_api_service(port, debug),
            )
            .await
            {
                let _ = log_error("api", "API systemd install failed", Some(&e)).await;
                return Err(ErrorFactory::operation(
                    "api",
                    "install xbp-api.service",
                    e,
                    Some("Check systemd availability and permissions, then retry."),
                ));
            }
            let _ = log_success(
                "api",
                &format!("xbp-api.service installed on port {}", port),
                None,
            )
            .await;
        }
    }
    Ok(())
}