Browse Source

feat(cli): add --continue and --fork flags to attach command (#13879)

Ryan Vogel 1 month ago
parent
commit
5cc1d6097e
1 changed files with 21 additions and 1 deletions
  1. 21 1
      packages/opencode/src/cli/cmd/tui/attach.ts

+ 21 - 1
packages/opencode/src/cli/cmd/tui/attach.ts

@@ -1,4 +1,5 @@
 import { cmd } from "../cmd"
+import { UI } from "@/cli/ui"
 import { tui } from "./app"
 import { win32DisableProcessedInput, win32InstallCtrlCGuard } from "./win32"
 
@@ -16,11 +17,20 @@ export const AttachCommand = cmd({
         type: "string",
         description: "directory to run in",
       })
+      .option("continue", {
+        alias: ["c"],
+        describe: "continue the last session",
+        type: "boolean",
+      })
       .option("session", {
         alias: ["s"],
         type: "string",
         describe: "session id to continue",
       })
+      .option("fork", {
+        type: "boolean",
+        describe: "fork the session when continuing (use with --continue or --session)",
+      })
       .option("password", {
         alias: ["p"],
         type: "string",
@@ -31,6 +41,12 @@ export const AttachCommand = cmd({
     try {
       win32DisableProcessedInput()
 
+      if (args.fork && !args.continue && !args.session) {
+        UI.error("--fork requires --continue or --session")
+        process.exitCode = 1
+        return
+      }
+
       const directory = (() => {
         if (!args.dir) return undefined
         try {
@@ -49,7 +65,11 @@ export const AttachCommand = cmd({
       })()
       await tui({
         url: args.url,
-        args: { sessionID: args.session },
+        args: {
+          continue: args.continue,
+          sessionID: args.session,
+          fork: args.fork,
+        },
         directory,
         headers,
       })