UNPKG

@xec-sh/cli

Version:

Xec: The Universal Shell for TypeScript

34 lines 1.1 kB
import { CommandRegistry } from '@xec-sh/core'; function extractCommandInfo(cmd) { const name = cmd.name(); const description = cmd.description(); const aliases = cmd.aliases(); const usage = cmd.usage() || `xec ${name} [options]`; return { command: name, description, aliases, usage }; } export function buildCommandRegistry(program) { const registry = new CommandRegistry(); if (program.name() && program.name() !== 'xec') { registry.register(extractCommandInfo(program)); } program.commands.forEach(cmd => { registry.register(extractCommandInfo(cmd)); if (cmd.commands && cmd.commands.length > 0) { cmd.commands.forEach(subCmd => { const info = extractCommandInfo(subCmd); info.command = `${cmd.name()} ${info.command}`; registry.register(info); }); } }); return registry; } export function registerCliCommands(program) { return buildCommandRegistry(program); } //# sourceMappingURL=command-registry.js.map