Skip to content

Commit af3afe2

Browse files
R44VC0RPbalcsida
authored andcommitted
feat(cli): add --continue and --fork flags to attach command (anomalyco#13879)
1 parent c10fc66 commit af3afe2

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

packages/opencode/src/cli/cmd/tui/attach.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { cmd } from "../cmd"
2+
import { UI } from "@/cli/ui"
23
import { tui } from "./app"
34
import { win32DisableProcessedInput, win32InstallCtrlCGuard } from "./win32"
45

@@ -16,11 +17,20 @@ export const AttachCommand = cmd({
1617
type: "string",
1718
description: "directory to run in",
1819
})
20+
.option("continue", {
21+
alias: ["c"],
22+
describe: "continue the last session",
23+
type: "boolean",
24+
})
1925
.option("session", {
2026
alias: ["s"],
2127
type: "string",
2228
describe: "session id to continue",
2329
})
30+
.option("fork", {
31+
type: "boolean",
32+
describe: "fork the session when continuing (use with --continue or --session)",
33+
})
2434
.option("password", {
2535
alias: ["p"],
2636
type: "string",
@@ -31,6 +41,12 @@ export const AttachCommand = cmd({
3141
try {
3242
win32DisableProcessedInput()
3343

44+
if (args.fork && !args.continue && !args.session) {
45+
UI.error("--fork requires --continue or --session")
46+
process.exitCode = 1
47+
return
48+
}
49+
3450
const directory = (() => {
3551
if (!args.dir) return undefined
3652
try {
@@ -49,7 +65,11 @@ export const AttachCommand = cmd({
4965
})()
5066
await tui({
5167
url: args.url,
52-
args: { sessionID: args.session },
68+
args: {
69+
continue: args.continue,
70+
sessionID: args.session,
71+
fork: args.fork,
72+
},
5373
directory,
5474
headers,
5575
})

0 commit comments

Comments
 (0)