GeezerVison is showing github.com — feat(cli): add --continue and --fork flags to attach command (#13879) · motionharvest/opencode@5cc1d60
File treeExpand file treeCollapse file tree Open diff view settings packages/opencode/src/cli/cmd/tui
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/cli/cmd/tui/attach.ts +21-1Lines changed: 21 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { cmd } from "../cmd" | | 2 | +import { UI } from "@/cli/ui" | 2 | 3 | import { tui } from "./app" | 3 | 4 | import { win32DisableProcessedInput, win32InstallCtrlCGuard } from "./win32" | 4 | 5 |
| @@ -16,11 +17,20 @@ export const AttachCommand = cmd({ | 16 | 17 | type: "string", | 17 | 18 | description: "directory to run in", | 18 | 19 | }) | | 20 | + .option("continue", { | | 21 | + alias: ["c"], | | 22 | + describe: "continue the last session", | | 23 | + type: "boolean", | | 24 | + }) | 19 | 25 | .option("session", { | 20 | 26 | alias: ["s"], | 21 | 27 | type: "string", | 22 | 28 | describe: "session id to continue", | 23 | 29 | }) | | 30 | + .option("fork", { | | 31 | + type: "boolean", | | 32 | + describe: "fork the session when continuing (use with --continue or --session)", | | 33 | + }) | 24 | 34 | .option("password", { | 25 | 35 | alias: ["p"], | 26 | 36 | type: "string", | @@ -31,6 +41,12 @@ export const AttachCommand = cmd({ | 31 | 41 | try { | 32 | 42 | win32DisableProcessedInput() | 33 | 43 |
| | 44 | + if (args.fork && !args.continue && !args.session) { | | 45 | + UI.error("--fork requires --continue or --session") | | 46 | + process.exitCode = 1 | | 47 | + return | | 48 | + } | | 49 | + | 34 | 50 | const directory = (() => { | 35 | 51 | if (!args.dir) return undefined | 36 | 52 | try { | @@ -49,7 +65,11 @@ export const AttachCommand = cmd({ | 49 | 65 | })() | 50 | 66 | await tui({ | 51 | 67 | url: args.url, | 52 | | - args: { sessionID: args.session }, | | 68 | + args: { | | 69 | + continue: args.continue, | | 70 | + sessionID: args.session, | | 71 | + fork: args.fork, | | 72 | + }, | 53 | 73 | directory, | 54 | 74 | headers, | 55 | 75 | }) | |
|