()
| 901 | // Commander supports compareOptions at runtime but @commander-js/extra-typings |
| 902 | // doesn't include it in the type definitions, so we use Object.assign to add it. |
| 903 | function createSortedHelpConfig(): { |
| 904 | sortSubcommands: true; |
| 905 | sortOptions: true; |
| 906 | } { |
| 907 | const getOptionSortKey = (opt: Option): string => opt.long?.replace(/^--/, '') ?? opt.short?.replace(/^-/, '') ?? ''; |
| 908 | return Object.assign({ |
| 909 | sortSubcommands: true, |
| 910 | sortOptions: true |
| 911 | } as const, { |
| 912 | compareOptions: (a: Option, b: Option) => getOptionSortKey(a).localeCompare(getOptionSortKey(b)) |
| 913 | }); |
| 914 | } |
| 915 | const program = new CommanderCommand().configureHelp(createSortedHelpConfig()).enablePositionalOptions(); |
| 916 | profileCheckpoint('run_commander_initialized'); |
| 917 |
no test coverage detected