cloudaxe-opencode/packages/opencode/src/cli/cmd/debug/snapshot.ts

53 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-07-01 16:06:38 +00:00
import { Snapshot } from "../../../snapshot"
import { bootstrap } from "../../bootstrap"
import { cmd } from "../cmd"
export const SnapshotCommand = cmd({
command: "snapshot",
2025-07-14 18:44:47 +00:00
builder: (yargs) => yargs.command(CreateCommand).command(RestoreCommand).command(DiffCommand).demandCommand(),
2025-07-01 16:06:38 +00:00
async handler() {},
})
2025-07-14 18:44:47 +00:00
const CreateCommand = cmd({
2025-07-01 16:06:38 +00:00
command: "create",
async handler() {
await bootstrap({ cwd: process.cwd() }, async () => {
const result = await Snapshot.create("test")
console.log(result)
})
},
})
2025-07-14 18:44:47 +00:00
const RestoreCommand = cmd({
2025-07-01 16:06:38 +00:00
command: "restore <commit>",
builder: (yargs) =>
yargs.positional("commit", {
type: "string",
description: "commit",
demandOption: true,
}),
async handler(args) {
await bootstrap({ cwd: process.cwd() }, async () => {
await Snapshot.restore("test", args.commit)
console.log("restored")
})
},
})
2025-07-14 18:44:47 +00:00
export const DiffCommand = cmd({
command: "diff <commit>",
describe: "diff",
builder: (yargs) =>
yargs.positional("commit", {
type: "string",
description: "commit",
demandOption: true,
}),
async handler(args) {
await bootstrap({ cwd: process.cwd() }, async () => {
const diff = await Snapshot.diff("test", args.commit)
console.log(diff)
})
},
})