/** * Destinations command for CLI. * * Lists available destinations for a server. * * @module */ import { isErr } from "@mks2508/no-throw"; import chalk from "chalk"; import Table from "cli-table3"; import { getCoolifyService } from "../../coolify/index.js"; /** * Destinations command handler. * * @param serverUuid - Server UUID */ export async function destinationsCommand(serverUuid: 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.getServerDestinations(serverUuid); if (isErr(result)) { console.error(chalk.red(`Error: ${result.error.message}`)); return; } const destinations = result.value; if (destinations.length === 0) { console.log(chalk.yellow("No destinations found")); return; } const table = new Table({ head: [chalk.cyan("UUID"), chalk.cyan("Name"), chalk.cyan("Network")], }); for (const dest of destinations) { table.push([dest.uuid, dest.name, dest.network || "N/A"]); } console.log(table.toString()); console.log(chalk.gray(`Total: ${destinations.length} destination(s)`)); }