Skip to content

Commit 10d9df2

Browse files
committed
cp dines
1 parent afde575 commit 10d9df2

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

src/cli.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,18 @@ snapshot
416416
deleteSnapshot(id, options);
417417
});
418418

419+
snapshot
420+
.command("get <id>")
421+
.description("Get snapshot details")
422+
.option(
423+
"-o, --output [format]",
424+
"Output format: text|json|yaml (default: json)",
425+
)
426+
.action(async (id, options) => {
427+
const { getSnapshot } = await import("./commands/snapshot/get.js");
428+
await getSnapshot({ id, ...options });
429+
});
430+
419431
snapshot
420432
.command("status <snapshot-id>")
421433
.description("Get snapshot operation status")

src/commands/snapshot/get.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* Get snapshot details command
3+
*/
4+
5+
import { getClient } from "../../utils/client.js";
6+
import { output, outputError } from "../../utils/output.js";
7+
8+
interface GetSnapshotOptions {
9+
id: string;
10+
output?: string;
11+
}
12+
13+
export async function getSnapshot(options: GetSnapshotOptions) {
14+
try {
15+
const client = getClient();
16+
17+
// This is the way to get snapshot details
18+
const snapshotDetails = await client.devboxes.diskSnapshots.queryStatus(
19+
options.id,
20+
);
21+
output(snapshotDetails, { format: options.output, defaultFormat: "json" });
22+
} catch (error) {
23+
outputError("Failed to get snapshot", error);
24+
}
25+
}

0 commit comments

Comments
 (0)