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