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.
54 lines (47 loc) • 1.41 kB
text/typescript
import { listGpuCloudVolumes } from "@/modules/gpu-cloud/use-cases/list-volumes";
import type { Command } from "commander";
import { DateTime } from "luxon";
interface TableData {
name: string;
"capacity (GB)": number;
provider: string;
region: string;
"price ($/hour)": string;
"created at": string;
}
export function createGpuCloudVolumeListCommand(
gpuCloudVolumeCommand: Command
) {
gpuCloudVolumeCommand
.command("list")
.description("List all GPU Cloud volumes")
.action(async () => {
const result = await listGpuCloudVolumes.execute();
if (result.isLeft()) {
console.error(result.value.message);
return;
}
const volumes = result.value;
if (volumes.length === 0) {
console.log("No volumes found");
return;
}
const tableData = volumes.reduce(
(dict, { _id, ...volume }) => {
dict[_id] = {
name: volume.name,
"capacity (GB)": volume.capacity,
provider: volume.availabilityZone,
region: volume.region.name,
"price ($/hour)": `$${volume.hourlyPrice.toFixed(2)}`,
"created at": DateTime.fromISO(volume.createdAt).toLocaleString(
DateTime.DATE_MED
),
};
return dict;
},
{} as Record<string, TableData>
);
console.table(tableData);
});
}