UNPKG

research-cli

Version:

AI-powered research assistant with web search capabilities and beautiful terminal UI

154 lines (153 loc) 6.8 kB
/** * Config commands - Clipanion implementation * * Configuration management commands for CLI settings and preferences */ import { Command, Option } from "clipanion"; // Base config command (shows help when used alone) export class ConfigCommand extends Command { static paths = [["config"]]; static usage = Command.Usage({ category: "Configuration", description: "⚙️ Manage CLI configuration", details: ` Manage CLI configuration settings and preferences. Configuration management is planned for M3 milestone. Currently provides placeholder commands for future extensibility. `, examples: [ ["Show current configuration", "$0 config show"], ["Initialize configuration", "$0 config init"], ["Set a configuration value", "$0 config set default_provider openai"], ["Get a configuration value", "$0 config get default_provider"], ], }); async execute() { this.context.stdout.write("⚙️ Configuration Management\n\n"); this.context.stdout.write("Available commands:\n"); this.context.stdout.write(" config init Initialize configuration file\n"); this.context.stdout.write(" config show Show current configuration\n"); this.context.stdout.write(" config set <key> <value> Set a configuration value\n"); this.context.stdout.write(" config get <key> Get a configuration value\n"); this.context.stdout.write(" config reset Reset configuration to defaults\n\n"); this.context.stdout.write("Use '$0 config <command> --help' for detailed information.\n"); return 0; } } // Init command export class ConfigInitCommand extends Command { static paths = [["config", "init"]]; static usage = Command.Usage({ category: "Configuration", description: "Initialize configuration file", }); async execute() { this.context.stdout.write("🔧 Initializing configuration...\n"); this.context.stdout.write("Configuration management will be fully implemented in M3 milestone\n"); this.context.stdout.write("\nFor now, you can:\n"); this.context.stdout.write(" • Use 'research-cli auth' commands to manage API keys\n"); this.context.stdout.write(" • Set provider with --provider option\n"); this.context.stdout.write(" • Configure options via command line flags\n"); return 0; } } // Show command export class ConfigShowCommand extends Command { static paths = [["config", "show"]]; static usage = Command.Usage({ category: "Configuration", description: "Show current configuration", }); async execute() { this.context.stdout.write("📋 Current Configuration:\n"); this.context.stdout.write("Configuration display will be implemented in M3 milestone\n"); this.context.stdout.write("\nCurrent status:\n"); this.context.stdout.write(" • API keys: Use 'research-cli auth list' to view\n"); this.context.stdout.write(" • Default provider: openai (configurable via --provider)\n"); this.context.stdout.write(" • Web search: enabled by default (--web/--no-web)\n"); return 0; } } // Reset command export class ConfigResetCommand extends Command { static paths = [["config", "reset"]]; static usage = Command.Usage({ category: "Configuration", description: "Reset configuration to defaults", examples: [ ["Reset with confirmation", "$0 config reset"], ["Reset without confirmation", "$0 config reset --force"], ], }); force = Option.Boolean("--force", false, { description: "Skip confirmation prompt", }); async execute() { if (!this.force) { const readline = await import("node:readline"); const rl = readline.createInterface({ input: process.stdin, output: process.stdout, }); const answer = await new Promise((resolve) => { rl.question("Reset all configuration to defaults? (y/N): ", resolve); }); rl.close(); if (!answer.toLowerCase().startsWith("y")) { this.context.stdout.write("Cancelled\n"); return 0; } } this.context.stdout.write("🔄 Resetting configuration...\n"); this.context.stdout.write("Configuration reset will be implemented in M3 milestone\n"); this.context.stdout.write("✅ Reset complete (when implemented)\n"); return 0; } } // Set command export class ConfigSetCommand extends Command { static paths = [["config", "set"]]; static usage = Command.Usage({ category: "Configuration", description: "Set a configuration value", examples: [ ["Set default provider", "$0 config set default_provider openai"], ["Set output format", "$0 config set output_format json"], ], }); key = Option.String({ required: true }); value = Option.String({ required: true }); async execute() { this.context.stdout.write(`⚙️ Setting ${this.key} = ${this.value}\n`); this.context.stdout.write("Configuration setting will be implemented in M3 milestone\n"); this.context.stdout.write("\nValid configuration keys (planned):\n"); this.context.stdout.write(" • default_provider\n"); this.context.stdout.write(" • web_search_enabled\n"); this.context.stdout.write(" • output_format\n"); this.context.stdout.write(" • max_tokens\n"); this.context.stdout.write(" • temperature\n"); return 0; } } // Get command export class ConfigGetCommand extends Command { static paths = [["config", "get"]]; static usage = Command.Usage({ category: "Configuration", description: "Get a configuration value", examples: [["Get default provider", "$0 config get default_provider"]], }); key = Option.String({ required: true }); async execute() { this.context.stdout.write(`📖 Getting value for: ${this.key}\n`); this.context.stdout.write("Configuration getting will be implemented in M3 milestone\n"); this.context.stdout.write("\nCurrent defaults:\n"); this.context.stdout.write(" • default_provider: openai\n"); this.context.stdout.write(" • web_search_enabled: true\n"); this.context.stdout.write(" • output_format: md\n"); this.context.stdout.write(" • max_tokens: (not set)\n"); this.context.stdout.write(" • temperature: (not set)\n"); return 0; } } //# sourceMappingURL=config.js.map