whodis-mcp-server
Version:
Whodis MCP Server for checking the availability of domain names using WHOIS lookups.
46 lines (45 loc) • 2.19 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.runCli = runCli;
const commander_1 = require("commander");
const logger_util_js_1 = require("../utils/logger.util.js");
const constants_util_js_1 = require("../utils/constants.util.js");
const domain_availability_cli_js_1 = __importDefault(require("./domain-availability.cli.js"));
/**
* CLI entry point for the Whodis MCP Server
* Handles command registration, parsing, and execution for domain availability checks.
*/
// Package description
const DESCRIPTION = 'Whodis MCP Server CLI - Utilities for checking domain name availability.';
/**
* Run the CLI with the provided arguments
*
* @param args Command line arguments to process
* @returns Promise that resolves when CLI command execution completes
*/
async function runCli(args) {
const cliLogger = logger_util_js_1.Logger.forContext('cli/index.ts', 'runCli');
cliLogger.debug('Initializing CLI with arguments', args);
const program = new commander_1.Command();
program.name(constants_util_js_1.CLI_NAME).description(DESCRIPTION).version(constants_util_js_1.VERSION);
// Register CLI commands
cliLogger.debug('Registering CLI commands...');
domain_availability_cli_js_1.default.register(program);
cliLogger.debug('CLI commands registered successfully');
// Handle unknown commands
program.on('command:*', (operands) => {
cliLogger.error(`Unknown command: ${operands[0]}`);
console.error(`\nError: Unknown command '${operands[0]}'. See --help for available commands.\n`);
program.outputHelp(); // Show help automatically
process.exit(1);
});
// Parse arguments; default to help if no command provided
cliLogger.debug('Parsing CLI arguments');
// Ensure '--help' is added if no arguments or only the script name is present
const argsToParse = args.length > 2 ? args : [...args, '--help'];
await program.parseAsync(argsToParse, { from: 'user' });
cliLogger.debug('CLI command execution completed');
}
;