/** * List command for CLI. * * @module */ import { isErr } from "@mks2508/no-throw"; import chalk from "chalk"; import Table from "cli-table3"; import { getCoolifyService } from "../../coolify/index.js"; import { formatStatus } from "../../utils/format.js"; /** * List command handler. * * @param options - List options */ export async function listCommand(options: { team?: string; project?: string; }) { const coolify = getCoolifyService(); const initResult = await coolify.init(); if (isErr(initResult)) { console.error(chalk.red(`Error: ${initResult.error.message}`)); return; } const result = await coolify.listApplications(options.team, options.project); if (isErr(result)) { console.error(chalk.red(`Error: ${result.error.message}`)); return; } const apps = result.value; if (apps.length === 0) { console.log(chalk.yellow("No applications found")); return; } // Usar ancho dinĂ¡mico basado en el contenido const table = new Table({ head: [ chalk.cyan("UUID"), chalk.cyan("Name"), chalk.cyan("Status"), chalk.cyan("Server"), ], }); for (const app of apps) { table.push([ app.uuid, app.name, formatStatus(app.status), app.destination?.server?.name || "N/A", ]); } console.log(table.toString()); console.log(chalk.gray(`Total: ${apps.length} application(s)`)); }