chatgpt-api/packages/cli/src/commands/signout.ts

23 wiersze
528 B
TypeScript
Czysty Zwykły widok Historia

2025-05-22 17:23:39 +00:00
import { Command } from 'commander'
import type { Context } from '../types'
2025-05-26 18:23:16 +00:00
import { AuthStore } from '../lib/auth-store'
2025-05-22 17:23:39 +00:00
export function registerSignoutCommand({ client, program, logger }: Context) {
const command = new Command('logout')
.alias('signout')
2025-05-26 19:13:30 +00:00
.description('Signs the current user out.')
2025-05-22 17:23:39 +00:00
.action(async () => {
2025-05-24 15:02:24 +00:00
if (!client.isAuthenticated) {
2025-05-22 17:23:39 +00:00
return
}
2025-05-24 15:02:24 +00:00
await client.logout()
2025-05-22 17:23:39 +00:00
AuthStore.clearAuth()
logger.log('Signed out')
})
program.addCommand(command)
}