forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnapshot.ts
More file actions
50 lines (46 loc) · 1.44 KB
/
snapshot.ts
File metadata and controls
50 lines (46 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { Effect } from "effect"
import { Snapshot } from "../../../snapshot"
import { effectCmd } from "../../effect-cmd"
import { cmd } from "../cmd"
export const SnapshotCommand = cmd({
command: "snapshot",
describe: "snapshot debugging utilities",
builder: (yargs) => yargs.command(TrackCommand).command(PatchCommand).command(DiffCommand).demandCommand(),
async handler() {},
})
const TrackCommand = effectCmd({
command: "track",
describe: "track current snapshot state",
handler: Effect.fn("Cli.debug.snapshot.track")(function* () {
const out = yield* Snapshot.Service.use((svc) => svc.track())
console.log(out)
}),
})
const PatchCommand = effectCmd({
command: "patch <hash>",
describe: "show patch for a snapshot hash",
builder: (yargs) =>
yargs.positional("hash", {
type: "string",
description: "hash",
demandOption: true,
}),
handler: Effect.fn("Cli.debug.snapshot.patch")(function* (args) {
const out = yield* Snapshot.Service.use((svc) => svc.patch(args.hash))
console.log(out)
}),
})
const DiffCommand = effectCmd({
command: "diff <hash>",
describe: "show diff for a snapshot hash",
builder: (yargs) =>
yargs.positional("hash", {
type: "string",
description: "hash",
demandOption: true,
}),
handler: Effect.fn("Cli.debug.snapshot.diff")(function* (args) {
const out = yield* Snapshot.Service.use((svc) => svc.diff(args.hash))
console.log(out)
}),
})