/** * Services command for CLI. * * Lists all services in Coolify. * * @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"; /** * Services command handler. * * @param options - Command options */ export async function servicesCommand(_options: { full?: boolean } = {}) { const coolify = getCoolifyService(); const initResult = await coolify.init(); if (isErr(initResult)) { console.error(chalk.red(`Error: ${initResult.error.message}`)); return; } const result = await coolify.listServices(); if (isErr(result)) { console.error(chalk.red(`Error: ${result.error.message}`)); return; } const services = result.value; if (services.length === 0) { console.log(chalk.yellow("No services found")); return; } const table = new Table({ head: [ chalk.cyan("UUID"), chalk.cyan("Name"), chalk.cyan("Type"), chalk.cyan("Status"), ], }); for (const svc of services) { table.push([ svc.uuid, svc.name || "-", svc.type || "-", formatStatus(svc.status), ]); } console.log(table.toString()); console.log(chalk.gray(`Total: ${services.length} service(s)`)); }