| 117 | const commandCache = new Map<string, Command>() |
| 118 | |
| 119 | function getOrCreateCommand(parent: Command, pathSegment: string): Command { |
| 120 | const fullPath = parent === program ? pathSegment : `${parent.name()} ${pathSegment}` |
| 121 | const cached = commandCache.get(fullPath) |
| 122 | if (cached) return cached |
| 123 | |
| 124 | const cmd = parent.command(pathSegment) |
| 125 | commandCache.set(fullPath, cmd) |
| 126 | return cmd |
| 127 | } |
| 128 | |
| 129 | type CommandSpec = (typeof commandSpecs)[number] |
| 130 | type OperationMeta = (typeof operationMeta)[keyof typeof operationMeta] |