use crate::commands::service::{is_xbp_project, load_xbp_config};
use crate::strategies::get_all_services;
use colored::Colorize;
use tracing::info;
pub async fn print_help() {
info!("\n{}", "XBP - eXtensible Build Pack".bright_blue().bold());
info!("{}\n", "═".repeat(60).dimmed());
info!("{} {}", "Usage:".bright_blue(), "xbp <command> [options]".yellow());
info!("");
info!("{}", "Commands:".bright_blue().bold());
info!(" {} - List active ports and processes", "ports".cyan());
info!(" {} - Run initial setup", "setup".cyan());
info!(" {} - Redeploy services", "redeploy".cyan());
info!(" {} - Show configuration", "config".cyan());
info!(" {} - Install packages", "install".cyan());
info!(" {} - View logs", "logs".cyan());
info!(" {} - List PM2 processes", "list".cyan());
info!(" {} - Start PM2 process", "start".cyan());
info!(" {} - Manage Nginx", "nginx".cyan());
info!(" {} - Run diagnostics", "diag".cyan());
info!(" {} - Monitor services", "monitor".cyan());
info!("");
if is_xbp_project().await {
info!("{}", "Service Commands:".bright_blue().bold());
info!(" {} - List all services", "services".cyan());
info!(" {} - Run service command", "service <cmd> <name>".cyan());
info!(" Commands: {}", "build, install, start, dev".yellow());
info!("");
if let Ok(config) = load_xbp_config().await {
let services = get_all_services(&config);
if !services.is_empty() {
info!("{}", "Available Services:".bright_green());
for service in services.iter().take(5) {
info!(" • {} {}:{}",
service.name.bright_cyan(),
service.target.dimmed(),
service.port.to_string().yellow()
);
}
if services.len() > 5 {
info!(" {} {} more", "...and".dimmed(), (services.len() - 5).to_string().dimmed());
}
info!("");
}
}
}
info!("{}", "Options:".bright_blue().bold());
info!(" {} - Enable debug output", "--debug".yellow());
info!(" {} - Show help message", "--help".yellow());
info!(" {} - Open logs directory", "--logs".yellow());
info!("");
info!("{}", "Examples:".bright_blue().bold());
info!(" {} - Kill processes on port 3000", "xbp ports -p 3000 --kill".dimmed());
info!(" {} - Install Docker", "xbp install docker".dimmed());
info!(" {} - Start a process with PM2", "xbp start \"npm start\" --name my-app".dimmed());
if is_xbp_project().await {
info!(" {} - Build a service", "xbp service build zeus".dimmed());
info!(" {} - Redeploy a service", "xbp redeploy zeus".dimmed());
}
info!("");
info!("For more information: {}", "https://github.com/yourusername/xbp".cyan());
}