mold-ai 0.2.0

Local AI image generation CLI — FLUX, SDXL, SD3.5, Z-Image diffusion models on your GPU
use anyhow::Result;
use colored::Colorize;

use crate::control::CliContext;
use crate::theme;
use crate::ui::print_server_unavailable;

pub async fn run() -> Result<()> {
    let ctx = CliContext::new(None);

    match ctx.client().server_status().await {
        Ok(status) => {
            println!("{} mold server v{}", theme::icon_ok(), status.version);
            println!("{} Uptime: {}s", theme::icon_ok(), status.uptime_secs,);

            if let Some(gpu) = &status.gpu_info {
                println!(
                    "{} GPU: {} ({}/{} MB VRAM)",
                    theme::icon_ok(),
                    gpu.name,
                    gpu.vram_used_mb,
                    gpu.vram_total_mb,
                );
            } else {
                println!("{} GPU: {}", theme::icon_ok(), "not detected".dimmed());
            }

            println!();
            if status.models_loaded.is_empty() {
                println!("{}", "No models loaded.".dimmed());
            } else {
                println!("{}", "Loaded models:".bold());
                for model in &status.models_loaded {
                    println!("  - {}", model.green());
                }
            }
        }
        Err(e) => {
            print_server_unavailable(ctx.client().host(), &e);
        }
    }

    Ok(())
}