UNPKG

logggai

Version:

AI-powered CLI for transforming your development work into professional content

80 lines 3.75 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.configCommand = configCommand; const chalk = require("chalk"); const { setConfig, getConfig, getAllConfig, clearConfig } = require('../lib/config'); async function configCommand(options) { console.log(chalk.default.blue.bold('Logggai CLI Configuration')); console.log(); // Définir une configuration if (options.set) { const [key, value] = options.set.split('='); if (!key || !value) { console.log(chalk.default.red('Invalid format. Use: --set key=value')); return; } // Configurations dangereuses - interdites aux utilisateurs finaux const restrictedKeys = ['apiUrl', 'sessionToken', 'userId', 'userEmail']; const validKeys = ['apiKey']; // Seules les clés non-sensibles sont autorisées if (restrictedKeys.includes(key)) { console.log(chalk.default.red(`⚠️ Configuration '${key}' cannot be modified.`)); console.log(chalk.default.yellow('This setting is managed automatically by the authentication system.')); console.log(chalk.default.gray('If you have connection issues, try: npx logggai logout && npx logggai login')); return; } if (!validKeys.includes(key)) { console.log(chalk.default.red(`Invalid key. Available keys: ${validKeys.join(', ')}`)); return; } setConfig(key, value); console.log(chalk.default.green(`${key} = ${key === 'apiKey' || key === 'sessionToken' ? '***' : value}`)); return; } // Obtenir une configuration if (options.get) { const value = getConfig(options.get); if (value === undefined) { console.log(chalk.default.yellow(`Configuration '${options.get}' not found`)); return; } const displayValue = (options.get === 'apiKey' || options.get === 'sessionToken') ? '***' : value; console.log(chalk.default.cyan(`${options.get} = ${displayValue}`)); return; } // Lister toutes les configurations if (options.list) { const config = getAllConfig(); const keys = Object.keys(config); if (keys.length === 0) { console.log(chalk.default.yellow('No configuration found')); console.log(chalk.default.gray('Use: logggai login')); return; } console.log(chalk.default.green('Current configurations:')); console.log(); keys.forEach(key => { const value = config[key]; const displayValue = (key === 'apiKey' || key === 'sessionToken') ? '***' : value; console.log(chalk.default.cyan(` ${key}`), chalk.default.gray('='), displayValue); }); console.log(); console.log(chalk.default.gray('Use --get <key> to see a value or --set <key>=<value> to modify')); return; } // Aucune option fournie, afficher l'aide console.log(chalk.default.yellow('No action specified')); console.log(); console.log(chalk.default.bold('Usage:')); console.log(chalk.default.cyan(' logggai config --list'), chalk.default.gray('# List all configurations')); console.log(chalk.default.cyan(' logggai config --get apiKey'), chalk.default.gray('# Get a configuration')); console.log(); console.log(chalk.default.bold('Available configurations for users:')); console.log(chalk.default.gray(' apiKey - Your personal API key')); console.log(); console.log(chalk.default.yellow('Note: System configurations (apiUrl, sessionToken, etc.) are managed automatically.')); } //# sourceMappingURL=config.js.map