()
| 888 | // Commander supports compareOptions at runtime but @commander-js/extra-typings |
| 889 | // doesn't include it in the type definitions, so we use Object.assign to add it. |
| 890 | function createSortedHelpConfig(): { |
| 891 | sortSubcommands: true; |
| 892 | sortOptions: true; |
| 893 | } { |
| 894 | const getOptionSortKey = (opt: Option): string => opt.long?.replace(/^--/, '') ?? opt.short?.replace(/^-/, '') ?? ''; |
| 895 | return Object.assign({ |
| 896 | sortSubcommands: true, |
| 897 | sortOptions: true |
| 898 | } as const, { |
| 899 | compareOptions: (a: Option, b: Option) => getOptionSortKey(a).localeCompare(getOptionSortKey(b)) |
| 900 | }); |
| 901 | } |
| 902 | const program = new CommanderCommand().configureHelp(createSortedHelpConfig()).enablePositionalOptions(); |
| 903 | profileCheckpoint('run_commander_initialized'); |
| 904 |
no test coverage detected