(command: CommanderCommand)
| 278 | } |
| 279 | |
| 280 | function getCommandOptions(command: CommanderCommand): { |
| 281 | options: string[] |
| 282 | valueOptions: string[] |
| 283 | } { |
| 284 | const options = new Set<string>(['-h', '--help']) |
| 285 | const valueOptions = new Set<string>() |
| 286 | |
| 287 | for (const option of command.options as CommanderOption[]) { |
| 288 | if (option.hidden) { |
| 289 | continue |
| 290 | } |
| 291 | if (option.short) { |
| 292 | options.add(option.short) |
| 293 | if (option.required || option.optional) { |
| 294 | valueOptions.add(option.short) |
| 295 | } |
| 296 | } |
| 297 | if (option.long) { |
| 298 | options.add(option.long) |
| 299 | if (option.required || option.optional) { |
| 300 | valueOptions.add(option.long) |
| 301 | } |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | return { |
| 306 | options: uniqSorted(options), |
| 307 | valueOptions: uniqSorted(valueOptions), |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | function collectCompletionTree( |
| 312 | command: CommanderCommand, |
no test coverage detected