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.

47 lines (39 loc) 1.4 kB
import { listSSHKeys } from "@/modules/ssh-keys/use-cases/list-ssh-keys"; import { makeSSHKeyDefault } from "@/modules/ssh-keys/use-cases/make-ssh-key-default"; import { select } from "@inquirer/prompts"; import type { Command } from "commander"; export function createSSHKeyMakeDefaultCommand(sshKeyCommand: Command) { sshKeyCommand .command("make-default") .description("Make a SSH key the default one") .option( "-i, --ssh-key-id <sshKeyId>", "The ID of the SSH key to make the default one" ) .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 make the default one", choices: sshKeys.map((sshKey) => ({ name: sshKey.name, value: sshKey._id, })), }); } console.log("Making SSH key the default one..."); const result = await makeSSHKeyDefault.execute(sshKeyId); if (result.isLeft()) { console.error(result.value.message); return; } console.log("SSH key made the default one successfully!"); }); }