(params: ReadonlyArray<FlagParam>)
| 230 | * @internal |
| 231 | */ |
| 232 | export const createFlagRegistry = (params: ReadonlyArray<FlagParam>): FlagRegistry => { |
| 233 | const index = new Map<string, FlagParam>() |
| 234 | |
| 235 | for (const param of params) { |
| 236 | if (index.has(param.name)) { |
| 237 | throw new Error(`Duplicate flag name "${param.name}" in command definition`) |
| 238 | } |
| 239 | index.set(param.name, param) |
| 240 | |
| 241 | for (const alias of param.aliases) { |
| 242 | if (index.has(alias)) { |
| 243 | throw new Error( |
| 244 | `Duplicate flag/alias "${alias}" in command definition (conflicts with "${index.get(alias)!.name}")` |
| 245 | ) |
| 246 | } |
| 247 | index.set(alias, param) |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | return { params, index } |
| 252 | } |
| 253 | |
| 254 | const buildSubcommandIndex = ( |
| 255 | subcommands: Command.Any["subcommands"] |
no test coverage detected