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.

63 lines 2.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createAIInferenceInstanceStopCommand = createAIInferenceInstanceStopCommand; const list_instances_1 = require("@/modules/ai-inference/use-cases/list-instances"); const stop_instance_1 = require("@/modules/ai-inference/use-cases/stop-instance"); const prompts_1 = require("@inquirer/prompts"); const printInstance = (instance) => { return `${instance.name} (${instance.features.join(", ")}) | ${instance.address} | ${instance.status} | ${instance.hourlyPrice.toFixed(2)}`; }; function createAIInferenceInstanceStopCommand(aiInferenceInstanceCommand) { aiInferenceInstanceCommand .command("stop") .description("Stop a launched instance in Sesterce AI Inference") .option("-i, --instance-id <instanceId>", "The ID of the instance to stop") .action(async (args) => { let instanceId = args.instanceId; if (!instanceId) { console.log("Loading inference instances..."); const result = await list_instances_1.listInferenceInstances.execute(); if (result.isLeft()) { console.error(result.value.message); return; } const instances = result.value; if (instances.length === 0) { console.log("No instances found"); return; } const instance = await (0, prompts_1.search)({ message: "Select an instance to start", source: async (input, { signal }) => { if (!input) { return instances.map((instance) => ({ name: printInstance(instance), value: instance, })); } return instances .filter((instance) => instance.name.toLowerCase().includes(input.toLowerCase()) || instance.address .toLowerCase() .includes(input.toLowerCase()) || instance.features.includes(input.toLowerCase()) || instance.status.toLowerCase().includes(input.toLowerCase()) || instance.name.toLowerCase().includes(input.toLowerCase()) || instance.hourlyPrice.toFixed(2).includes(input)) .map((instance) => ({ name: printInstance(instance), value: instance, })); }, }); instanceId = instance._id; } const result = await stop_instance_1.stopInferenceInstance.execute(instanceId); if (result.isLeft()) { console.error(result.value.message); return; } console.log("Instance stopped successfully"); }); } //# sourceMappingURL=stop.js.map