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.

44 lines (36 loc) 1.28 kB
import { deleteSSHKey } from "@/modules/ssh-keys/use-cases/delete-ssh-key"; import { listSSHKeys } from "@/modules/ssh-keys/use-cases/list-ssh-keys"; import { select } from "@inquirer/prompts"; import type { Command } from "commander"; export function createSSHKeyDeleteCommand(sshKeyCommand: Command) { sshKeyCommand .command("delete") .description("Delete a SSH key") .option("-i, --ssh-key-id <sshKeyId>", "The ID of the SSH key to delete") .action(async (args) => { let sshKeyId = args.sshKeyId; if (!sshKeyId) { console.log("Loading SSH keys..."); const result = await listSSHKeys.execute(); if (result.isLeft()) { console.error(result.value.message); return; } const sshKeys = result.value; sshKeyId = await select({ message: "Select the SSH key to delete", choices: sshKeys.map((sshKey) => ({ name: sshKey.name, value: sshKey._id, })), }); } console.log("Deleting SSH key..."); const result = await deleteSSHKey.execute(sshKeyId); if (result.isLeft()) { console.error(result.value.message); return; } console.log("SSH key deleted successfully!"); }); }