@ace-sdk/cli
Version:
ACE CLI - Command-line tool for intelligent pattern learning and playbook management
52 lines • 1.57 kB
JavaScript
/**
* Logout Command - Clear authentication credentials
* @package @ace-sdk/cli
*/
import chalk from 'chalk';
import { logout, isAuthenticated, getCurrentUser } from '@ace-sdk/core';
import { globalOptions } from '../cli.js';
export async function logoutCommand() {
// Check if logged in
if (!isAuthenticated()) {
if (globalOptions.json) {
console.log(JSON.stringify({
warning: 'Not logged in',
success: true
}));
}
else {
console.log(chalk.yellow('Not logged in'));
}
return;
}
const user = getCurrentUser();
try {
logout();
if (globalOptions.json) {
console.log(JSON.stringify({
success: true,
message: 'Logged out successfully',
user: user ? { email: user.email } : null
}));
}
else {
console.log(chalk.green('Logged out successfully'));
if (user) {
console.log(chalk.gray('Was logged in as:'), chalk.cyan(user.email));
}
}
}
catch (error) {
if (globalOptions.json) {
console.error(JSON.stringify({
error: true,
message: error instanceof Error ? error.message : String(error)
}));
}
else {
console.error(chalk.red('Failed to logout:'), error instanceof Error ? error.message : String(error));
}
process.exit(1);
}
}
//# sourceMappingURL=logout.js.map