@noanswer/context-compose
Version:
Orchestrate complex AI interactions with Context Compose. A powerful CLI and server for building, validating, and managing context for large language models using the Model Context Protocol (MCP).
79 lines β’ 2.75 kB
JavaScript
import { Command } from 'commander';
import { EnvLoader } from '../../core/env.js';
/**
* Create environment variable command
*/
export function createEnvCommand() {
const envCommand = new Command('env');
envCommand
.description('Check environment variable configuration status')
.option('-s, --setup', 'Show .env file setup guide')
.action(async (options) => {
try {
if (options.setup) {
showEnvSetupGuide();
}
else {
// Display overall environment variable status
EnvLoader.printStatus();
}
}
catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
console.error(`β Error checking environment variables: ${errorMessage}`);
process.exit(1);
}
});
// Improve help
envCommand.on('--help', () => {
console.log('');
console.log('Usage examples:');
console.log(' $ mcp-tool env');
console.log(' $ mcp-tool env --setup');
console.log('');
console.log('Description:');
console.log(' This command checks .env file and environment variable configuration status.');
});
return envCommand;
}
/**
* Show .env file setup guide
*/
function showEnvSetupGuide() {
console.log('π§ .env File Setup Guide');
console.log('');
console.log('1. Create .env file in project root:');
console.log(' $ touch .env');
console.log('');
console.log('2. Add the following content to .env file:');
console.log('');
console.log('# OpenWeather API Key');
console.log('OPENWEATHER_API_KEY=your_api_key_here');
console.log('');
console.log('# GitHub Token');
console.log('GITHUB_TOKEN=your_github_token_here');
console.log('');
console.log('3. Verify configuration:');
console.log(' $ mcp-tool env');
console.log('');
console.log('π‘ You can set other environment variables by referring to .env.example file.');
}
/**
* νκ²½λ³μ λͺ
λ Ή μ¬μ© μμ νμ
*/
export function showEnvExamples() {
console.log('π§ νκ²½λ³μ λͺ
λ Ή μ¬μ© μμ:');
console.log('');
console.log('κΈ°λ³Έ μ¬μ©λ²:');
console.log(' $ mcp-tool env');
console.log(' β μ 체 νκ²½λ³μ μν νμΈ');
console.log('');
console.log('μ€μ κ°μ΄λ:');
console.log(' $ mcp-tool env --setup');
console.log(' β .env νμΌ μ€μ λ°©λ² μλ΄');
console.log('');
console.log('νκ²½λ³μ νμΌ:');
console.log(' π .env (μ€μ μ€μ νμΌ)');
console.log(' π .env.example (μμ νμΌ)');
}
//# sourceMappingURL=env.js.map