()
| 1070 | // Commander supports compareOptions at runtime but @commander-js/extra-typings |
| 1071 | // doesn't include it in the type definitions, so we use Object.assign to add it. |
| 1072 | function createSortedHelpConfig(): { |
| 1073 | sortSubcommands: true; |
| 1074 | sortOptions: true; |
| 1075 | } { |
| 1076 | const getOptionSortKey = (opt: Option): string => |
| 1077 | opt.long?.replace(/^--/, '') ?? opt.short?.replace(/^-/, '') ?? ''; |
| 1078 | return Object.assign({ sortSubcommands: true, sortOptions: true } as const, { |
| 1079 | compareOptions: (a: Option, b: Option) => getOptionSortKey(a).localeCompare(getOptionSortKey(b)), |
| 1080 | }); |
| 1081 | } |
| 1082 | const program = new CommanderCommand().configureHelp(createSortedHelpConfig()).enablePositionalOptions(); |
| 1083 | profileCheckpoint('run_commander_initialized'); |
| 1084 |
no test coverage detected