feat(cli): add session delete command (#13571)
This commit is contained in:
@@ -359,6 +359,7 @@ opencode serve --hostname 0.0.0.0 --port 4096
|
|||||||
opencode serve [--port <number>] [--hostname <string>] [--cors <origin>]
|
opencode serve [--port <number>] [--hostname <string>] [--cors <origin>]
|
||||||
opencode session [command]
|
opencode session [command]
|
||||||
opencode session list
|
opencode session list
|
||||||
|
opencode session delete <sessionID>
|
||||||
opencode stats
|
opencode stats
|
||||||
opencode uninstall
|
opencode uninstall
|
||||||
opencode upgrade
|
opencode upgrade
|
||||||
|
|||||||
@@ -38,10 +38,34 @@ function pagerCmd(): string[] {
|
|||||||
export const SessionCommand = cmd({
|
export const SessionCommand = cmd({
|
||||||
command: "session",
|
command: "session",
|
||||||
describe: "manage sessions",
|
describe: "manage sessions",
|
||||||
builder: (yargs: Argv) => yargs.command(SessionListCommand).demandCommand(),
|
builder: (yargs: Argv) => yargs.command(SessionListCommand).command(SessionDeleteCommand).demandCommand(),
|
||||||
async handler() {},
|
async handler() {},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const SessionDeleteCommand = cmd({
|
||||||
|
command: "delete <sessionID>",
|
||||||
|
describe: "delete a session",
|
||||||
|
builder: (yargs: Argv) => {
|
||||||
|
return yargs.positional("sessionID", {
|
||||||
|
describe: "session ID to delete",
|
||||||
|
type: "string",
|
||||||
|
demandOption: true,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handler: async (args) => {
|
||||||
|
await bootstrap(process.cwd(), async () => {
|
||||||
|
try {
|
||||||
|
await Session.get(args.sessionID)
|
||||||
|
} catch {
|
||||||
|
UI.error(`Session not found: ${args.sessionID}`)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
await Session.remove(args.sessionID)
|
||||||
|
UI.println(UI.Style.TEXT_SUCCESS_BOLD + `Session ${args.sessionID} deleted` + UI.Style.TEXT_NORMAL)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
export const SessionListCommand = cmd({
|
export const SessionListCommand = cmd({
|
||||||
command: "list",
|
command: "list",
|
||||||
describe: "list sessions",
|
describe: "list sessions",
|
||||||
|
|||||||
Reference in New Issue
Block a user