UNPKG

sesterce-cli

Version:

A powerful command-line interface tool for managing Sesterce Cloud services. Sesterce CLI provides easy access to GPU cloud instances, AI inference services, container registries, and SSH key management directly from your terminal.

43 lines (36 loc) 1.09 kB
import { listSSHKeys } from "@/modules/ssh-keys/use-cases/list-ssh-keys"; import type { Command } from "commander"; import { DateTime } from "luxon"; interface TableData { name: string; default: string; "created at": string; } export function createSSHKeyListCommand(sshKeyCommand: Command) { sshKeyCommand .command("list") .description("List all SSH keys") .action(async () => { console.log("Listing SSH keys..."); const result = await listSSHKeys.execute(); if (result.isLeft()) { console.error(result.value.message); return; } const sshKeys = result.value; const tableData = sshKeys.reduce( (dict, { _id: id, ...sshKey }) => { dict[id] = { name: sshKey.name, default: sshKey.isDefault ? "Yes" : "No", "created at": DateTime.fromISO(sshKey.createdAt).toLocaleString( DateTime.DATE_MED ), }; return dict; }, {} as Record<string, TableData> ); console.table(tableData); }); }