()
| 950 | // Commander supports compareOptions at runtime but @commander-js/extra-typings |
| 951 | // doesn't include it in the type definitions, so we use Object.assign to add it. |
| 952 | function createSortedHelpConfig(): { |
| 953 | sortSubcommands: true; |
| 954 | sortOptions: true; |
| 955 | } { |
| 956 | const getOptionSortKey = (opt: Option): string => opt.long?.replace(/^--/, '') ?? opt.short?.replace(/^-/, '') ?? ''; |
| 957 | return Object.assign({ |
| 958 | sortSubcommands: true, |
| 959 | sortOptions: true |
| 960 | } as const, { |
| 961 | compareOptions: (a: Option, b: Option) => getOptionSortKey(a).localeCompare(getOptionSortKey(b)) |
| 962 | }); |
| 963 | } |
| 964 | const program = new CommanderCommand().configureHelp(createSortedHelpConfig()).enablePositionalOptions(); |
| 965 | profileCheckpoint('run_commander_initialized'); |
| 966 |
no test coverage detected