index.test-d.ts
This file
Path
typings/index.test-d.ts
787 lines · 24.7 KiB · TypeScript
Last changed by
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
History of this fileTake it
The walk stopped after 200 commits: lines older than 471ec40 point at it.
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
line 1why, one step back1import * as commander from './index.js';Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 2–3why, one step back2import { expectType } from 'tsd';3Merge branch 'develop' into release/13.xJohn Geebefore adoption5a79585
line 4why, one step back4// We are not just checking return types here, we are also implicitly checking that the expected syntax is allowed.Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 5–17why, one step back56const program: commander.Command = new commander.Command();7// @ts-expect-error Check that Command is strongly typed and does not allow arbitrary properties8// eslint-disable-next-line @typescript-eslint/no-unused-expressions9program.silly; // <-- Error, hurrah!1011// Check for exported global Command object12expectType<commander.Command>(commander.program);1314// Check export classes and functions exist15expectType<commander.Command>(new commander.Command());16expectType<commander.Command>(new commander.Command('name'));17expectType<commander.Option>(new commander.Option('-f'));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 18–26why, one step back18expectType<commander.CommanderError>(19 new commander.CommanderError(1, 'code', 'message'),20);21expectType<commander.InvalidArgumentError>(22 new commander.InvalidArgumentError('message'),23);24expectType<commander.InvalidArgumentError>(25 new commander.InvalidOptionArgumentError('message'),26);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 27–34why, one step back27expectType<commander.Command>(commander.createCommand());28expectType<commander.Option>(commander.createOption('--demo'));29expectType<commander.Argument>(commander.createArgument('<foo>'));3031// Command properties32expectType<string[]>(program.args);33// eslint-disable-next-line @typescript-eslint/no-explicit-any34expectType<any[]>(program.processedArgs);Add Command.options to TypeScript (#1827)John Geebefore adoption04fc0fd
lines 35–36why, one step back35expectType<readonly commander.Command[]>(program.commands);36expectType<readonly commander.Option[]>(program.options);Add public Arguments property (#2010)John Geebefore adoption7d23437
line 37why, one step back37expectType<readonly commander.Argument[]>(program.registeredArguments);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 38–42why, one step back38expectType<commander.Command | null>(program.parent);3940// version41expectType<commander.Command>(program.version('1.2.3'));42expectType<commander.Command>(program.version('1.2.3', '-r,--revision'));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 43–45why, one step back43expectType<commander.Command>(44 program.version('1.2.3', '-r,--revision', 'show revision information'),45);Types for version getter (#1982)John Geebefore adoptionf5413db
line 46why, one step back46expectType<string | undefined>(program.version());Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 47–49why, one step back4748// command (and CommandOptions)49expectType<commander.Command>(program.command('action'));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 50–52why, one step back50expectType<commander.Command>(51 program.command('action', { isDefault: true, hidden: true, noHelp: true }),52);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 53why, one step back53expectType<commander.Command>(program.command('exec', 'exec description'));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 54–61why, one step back54expectType<commander.Command>(55 program.command('exec', 'exec description', {56 isDefault: true,57 hidden: true,58 noHelp: true,59 executableFile: 'foo',60 }),61);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 62–68why, one step back6263// addCommand64expectType<commander.Command>(program.addCommand(new commander.Command('abc')));6566// argument67expectType<commander.Command>(program.argument('<value>'));68expectType<commander.Command>(program.argument('<value>', 'description'));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 69–77why, one step back69expectType<commander.Command>(70 program.argument('[value]', 'description', 'default'),71);72expectType<commander.Command>(73 program.argument('[value]', 'description', parseFloat),74);75expectType<commander.Command>(76 program.argument('[value]', 'description', parseFloat, 1.23),77);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 78–82why, one step back7879// arguments80expectType<commander.Command>(program.arguments('<cmd> [env]'));8182// addHelpCommandReformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 83–85why, one step back83expectType<commander.Command>(84 program.addHelpCommand(new commander.Command('assist')),85);Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1
line 86why, one step back86// Deprecated usesAdd copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 87–89why, one step back87expectType<commander.Command>(program.addHelpCommand());88expectType<commander.Command>(program.addHelpCommand(false));89expectType<commander.Command>(program.addHelpCommand(true));Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1
line 90why, one step back90expectType<commander.Command>(program.addHelpCommand('assist [cmd]'));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 91–93why, one step back91expectType<commander.Command>(92 program.addHelpCommand('assist [file]', 'display help'),93);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 94why, one step back94Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1
lines 95–98why, one step back95// helpCommand96expectType<commander.Command>(program.helpCommand(false));97expectType<commander.Command>(program.helpCommand(true));98expectType<commander.Command>(program.helpCommand('assist [cmd]'));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 99–101why, one step back99expectType<commander.Command>(100 program.helpCommand('assist [file]', 'display help'),101);Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1
line 102why, one step back102Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 103–104why, one step back103// exitOverride104expectType<commander.Command>(program.exitOverride());Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 105–118why, one step back105expectType<commander.Command>(106 program.exitOverride((err): never => {107 return process.exit(err.exitCode);108 }),109);110expectType<commander.Command>(111 program.exitOverride((err): void => {112 if (err.code !== 'commander.executeSubCommandAsync') {113 throw err;114 } else {115 // Async callback from spawn events, not useful to throw.116 }117 }),118);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 119–128why, one step back119120// error121expectType<never>(program.error('Goodbye'));122expectType<never>(program.error('Goodbye', { code: 'my.error' }));123expectType<never>(program.error('Goodbye', { exitCode: 2 }));124expectType<never>(program.error('Goodbye', { code: 'my.error', exitCode: 2 }));125126// hook127expectType<commander.Command>(program.hook('preAction', () => {}));128expectType<commander.Command>(program.hook('postAction', () => {}));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 129–136why, one step back129expectType<commander.Command>(program.hook('preAction', async () => {}));130expectType<commander.Command>(131 program.hook('preAction', (thisCommand, actionCommand) => {132 // implicit parameter types133 expectType<commander.Command>(thisCommand);134 expectType<commander.Command>(actionCommand);135 }),136);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 137why, one step back137expectType<commander.Command>(program.hook('preSubcommand', () => {}));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 138–144why, one step back138expectType<commander.Command>(139 program.hook('preSubcommand', (thisCommand, subcommand) => {140 // implicit parameter types141 expectType<commander.Command>(thisCommand);142 expectType<commander.Command>(subcommand);143 }),144);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 145–147why, one step back145146// action147expectType<commander.Command>(program.action(() => {}));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 148why, one step back148expectType<commander.Command>(program.action(async () => {}));Feature/run all checks (#2210)John Geebefore adoption3fa29f7
lines 149–151why, one step back149program.action(function () {150 expectType<typeof program>(this);151});Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 152–155why, one step back152153// option154expectType<commander.Command>(program.option('-a,--alpha'));155expectType<commander.Command>(program.option('-p, --peppers', 'Add peppers'));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 156–164why, one step back156expectType<commander.Command>(157 program.option('-s, --string [value]', 'default string', 'value'),158);159expectType<commander.Command>(160 program.option('-b, --boolean', 'default boolean', false),161);162expectType<commander.Command>(163 program.option('--drink <size', 'drink size', /small|medium|large/),164); // deprecatedAdd copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 165–183why, one step back165166// example coercion functions from README167168function myParseInt(value: string): number {169 return parseInt(value);170}171172function increaseVerbosity(dummyValue: string, previous: number): number {173 return previous + 1;174}175176function collect(value: string, previous: string[]): string[] {177 return previous.concat([value]);178}179180function commaSeparatedList(value: string): string[] {181 return value.split(',');182}183Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 184–213why, one step back184expectType<commander.Command>(185 program.option('-f, --float <number>', 'float argument', parseFloat),186);187expectType<commander.Command>(188 program.option('-f, --float <number>', 'float argument', parseFloat, 3.2),189);190expectType<commander.Command>(191 program.option('-i, --integer <number>', 'integer argument', myParseInt),192);193expectType<commander.Command>(194 program.option('-i, --integer <number>', 'integer argument', myParseInt, 5),195);196expectType<commander.Command>(197 program.option(198 '-v, --verbose',199 'verbosity that can be increased',200 increaseVerbosity,201 0,202 ),203);204expectType<commander.Command>(205 program.option('-c, --collect <value>', 'repeatable value', collect, []),206);207expectType<commander.Command>(208 program.option(209 '-l, --list <items>',210 'comma separated list',211 commaSeparatedList,212 ),213);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 214–216why, one step back214215// requiredOption, same tests as option216expectType<commander.Command>(program.requiredOption('-a,--alpha'));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 217–228why, one step back217expectType<commander.Command>(218 program.requiredOption('-p, --peppers', 'Add peppers'),219);220expectType<commander.Command>(221 program.requiredOption('-s, --string [value]', 'default string', 'value'),222);223expectType<commander.Command>(224 program.requiredOption('-b, --boolean', 'default boolean', false),225);226expectType<commander.Command>(227 program.requiredOption('--drink <size', 'drink size', /small|medium|large/),228); // deprecatedAdd copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 229why, one step back229Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 230–278why, one step back230expectType<commander.Command>(231 program.requiredOption('-f, --float <number>', 'float argument', parseFloat),232);233expectType<commander.Command>(234 program.requiredOption(235 '-f, --float <number>',236 'float argument',237 parseFloat,238 3.2,239 ),240);241expectType<commander.Command>(242 program.requiredOption(243 '-i, --integer <number>',244 'integer argument',245 myParseInt,246 ),247);248expectType<commander.Command>(249 program.requiredOption(250 '-i, --integer <number>',251 'integer argument',252 myParseInt,253 5,254 ),255);256expectType<commander.Command>(257 program.requiredOption(258 '-v, --verbose',259 'verbosity that can be increased',260 increaseVerbosity,261 0,262 ),263);264expectType<commander.Command>(265 program.requiredOption(266 '-c, --collect <value>',267 'repeatable value',268 collect,269 [],270 ),271);272expectType<commander.Command>(273 program.requiredOption(274 '-l, --list <items>',275 'comma separated list',276 commaSeparatedList,277 ),278);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 279–284why, one step back279280// createOption281expectType<commander.Option>(program.createOption('a, --alpha'));282expectType<commander.Option>(program.createOption('a, --alpha', 'description'));283284// addOptionReformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 285–287why, one step back285expectType<commander.Command>(286 program.addOption(new commander.Option('-s,--simple')),287);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 288–289why, one step back288289// storeOptionsAsPropertiesReformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 290–295why, one step back290expectType<commander.Command & commander.OptionValues>(291 program.storeOptionsAsProperties(),292);293expectType<commander.Command & commander.OptionValues>(294 program.storeOptionsAsProperties(true),295);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 296–305why, one step back296expectType<commander.Command>(program.storeOptionsAsProperties(false));297298// getOptionValue299void program.getOptionValue('example');300301// setOptionValue302expectType<commander.Command>(program.setOptionValue('example', 'value'));303expectType<commander.Command>(program.setOptionValue('example', true));304305// setOptionValueWithSourceReformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 306–308why, one step back306expectType<commander.Command>(307 program.setOptionValueWithSource('example', [], 'cli'),308);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 309–310why, one step back309310// getOptionValueSourceReformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 311–313why, one step back311expectType<commander.OptionValueSource | undefined>(312 program.getOptionValueSource('example'),313);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 314why, one step back314Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631
line 315why, one step back315// getOptionValueSourceWithGlobalsReformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 316–318why, one step back316expectType<commander.OptionValueSource | undefined>(317 program.getOptionValueSourceWithGlobals('example'),318);Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631
line 319why, one step back319Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 320–342why, one step back320// combineFlagAndOptionalValue321expectType<commander.Command>(program.combineFlagAndOptionalValue());322expectType<commander.Command>(program.combineFlagAndOptionalValue(false));323324// allowUnknownOption325expectType<commander.Command>(program.allowUnknownOption());326expectType<commander.Command>(program.allowUnknownOption(false));327328// allowExcessArguments329expectType<commander.Command>(program.allowExcessArguments());330expectType<commander.Command>(program.allowExcessArguments(false));331332// enablePositionalOptions333expectType<commander.Command>(program.enablePositionalOptions());334expectType<commander.Command>(program.enablePositionalOptions(false));335336// passThroughOptions337expectType<commander.Command>(program.passThroughOptions());338expectType<commander.Command>(program.passThroughOptions(false));339340// parse341expectType<commander.Command>(program.parse());342expectType<commander.Command>(program.parse(process.argv));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 343–348why, one step back343expectType<commander.Command>(344 program.parse(['node', 'script.js'], { from: 'node' }),345);346expectType<commander.Command>(347 program.parse(['node', 'script.js'], { from: 'electron' }),348);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 349–354why, one step back349expectType<commander.Command>(program.parse(['--option'], { from: 'user' }));350expectType<commander.Command>(program.parse(['node', 'script.js'] as const));351352// parseAsync, same tests as parse353expectType<Promise<commander.Command>>(program.parseAsync());354expectType<Promise<commander.Command>>(program.parseAsync(process.argv));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 355–366why, one step back355expectType<Promise<commander.Command>>(356 program.parseAsync(['node', 'script.js'], { from: 'node' }),357);358expectType<Promise<commander.Command>>(359 program.parseAsync(['node', 'script.js'], { from: 'electron' }),360);361expectType<Promise<commander.Command>>(362 program.parseAsync(['--option'], { from: 'user' }),363);364expectType<Promise<commander.Command>>(365 program.parseAsync(['node', 'script.js'] as const),366);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 367–368why, one step back367368// parseOptions (and ParseOptionsResult)Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 369–371why, one step back369expectType<{ operands: string[]; unknown: string[] }>(370 program.parseOptions(['node', 'script.js', 'hello']),371);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 372why, one step back372Add save/restore state to allow multiple calls to parse (#2299)John Geebefore adoption49423a2
lines 373–376why, one step back373// save/restore state374expectType<void>(program.saveStateBeforeParse());375expectType<void>(program.restoreStateBeforeParse());376Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 377–406why, one step back377// opts378const opts = program.opts();379expectType<commander.OptionValues>(opts);380expectType(opts.foo);381expectType(opts.bar);382383// opts with generics384interface MyCheeseOption {385 cheese: string;386}387const myCheeseOption = program.opts<MyCheeseOption>();388expectType<string>(myCheeseOption.cheese);389// @ts-expect-error Check that options strongly typed and does not allow arbitrary properties390expectType(myCheeseOption.foo);391392// optsWithGlobals393const optsWithGlobals = program.optsWithGlobals();394expectType<commander.OptionValues>(optsWithGlobals);395expectType(optsWithGlobals.foo);396expectType(optsWithGlobals.bar);397398// optsWithGlobals with generics399const myCheeseOptionWithGlobals = program.optsWithGlobals<MyCheeseOption>();400expectType<string>(myCheeseOptionWithGlobals.cheese);401// @ts-expect-error Check that options strongly typed and does not allow arbitrary properties402expectType(myCheeseOptionWithGlobals.foo);403404// description405expectType<commander.Command>(program.description('my description'));406expectType<string>(program.description());Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 407–411why, one step back407expectType<commander.Command>(408 program.description('my description of command with arg foo', {409 foo: 'foo description',410 }),411); // deprecatedAdd copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 412–422why, one step back412413// summary414expectType<commander.Command>(program.summary('my summary'));415expectType<string>(program.summary());416417// alias418expectType<commander.Command>(program.alias('my alias'));419expectType<string>(program.alias());420421// aliases422expectType<commander.Command>(program.aliases(['first-alias', 'second-alias']));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 423–425why, one step back423expectType<commander.Command>(424 program.aliases(['first-alias', 'second-alias'] as const),425);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 426–435why, one step back426expectType<string[]>(program.aliases());427428// usage429expectType<commander.Command>(program.usage('my usage'));430expectType<string>(program.usage());431432// name433expectType<commander.Command>(program.name('my-name'));434expectType<string>(program.name());435Add typings for helpGroup support (#2367)John Geebefore adoptiondd7edf4
lines 436–445why, one step back436// helpGroup related437expectType<commander.Command>(program.helpGroup('My Group'));438expectType<string>(program.helpGroup());439440expectType<commander.Command>(program.commandsGroup('My Group'));441expectType<string>(program.commandsGroup());442443expectType<commander.Command>(program.optionsGroup('My Group'));444expectType<string>(program.optionsGroup());445Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 446why, one step back446// nameFromFilenameSwitching to esm-only (#2464)John Geebefore adoptionf4bd470
line 447why, one step back447expectType<commander.Command>(program.nameFromFilename(import.meta.filename));Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 448–449why, one step back448449// executableDirSwitching to esm-only (#2464)John Geebefore adoptionf4bd470
line 450why, one step back450expectType<commander.Command>(program.executableDir(import.meta.dirname));Fix executableDir() return typeWee Bitbefore adoption68a4276
line 451why, one step back451expectType<string | null>(program.executableDir());Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 452–454why, one step back452453// outputHelp454expectType<void>(program.outputHelp());Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 455–459why, one step back455expectType<void>(456 program.outputHelp((str: string) => {457 return str;458 }),459);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 460–463why, one step back460expectType<void>(program.outputHelp({ error: true }));461462// help463expectType<never>(program.help());Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 464–468why, one step back464expectType<never>(465 program.help((str: string) => {466 return str;467 }),468);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 469–476why, one step back469expectType<never>(program.help({ error: true }));470471// helpInformation472expectType<string>(program.helpInformation());473expectType<string>(program.helpInformation({ error: true }));474475// helpOption476expectType<commander.Command>(program.helpOption('-h,--help'));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 477–482why, one step back477expectType<commander.Command>(478 program.helpOption('-h,--help', 'custom description'),479);480expectType<commander.Command>(481 program.helpOption(undefined, 'custom description'),482);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 483why, one step back483expectType<commander.Command>(program.helpOption(false));Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1
lines 484–485why, one step back484485// addHelpOptionReformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 486–488why, one step back486expectType<commander.Command>(487 program.addHelpOption(new commander.Option('-h,--help')),488);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 489–493why, one step back489490// addHelpText491expectType<commander.Command>(program.addHelpText('after', 'text'));492expectType<commander.Command>(program.addHelpText('afterAll', 'text'));493expectType<commander.Command>(program.addHelpText('before', () => 'before'));Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 494–500why, one step back494expectType<commander.Command>(495 program.addHelpText('beforeAll', (context) => {496 expectType<boolean>(context.error);497 expectType<commander.Command>(context.command);498 return '';499 }),500);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 501–522why, one step back501502// on503expectType<commander.Command>(program.on('command:foo', () => {}));504505// createCommand506expectType<commander.Command>(program.createCommand());507expectType<commander.Command>(program.createCommand('name'));508509class MyCommand extends commander.Command {510 createCommand(name?: string): MyCommand {511 return new MyCommand(name);512 }513514 myFunction(): void {515 // do nothing.516 }517}518const myProgram = new MyCommand();519expectType<MyCommand>(myProgram.command('sub'));520521// configureHelp522expectType<commander.Help>(program.createHelp());Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 523–528why, one step back523expectType<commander.Command>(524 program.configureHelp({525 sortSubcommands: true, // override property526 visibleCommands: () => [], // override method527 }),528);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 529–531why, one step back529expectType<commander.HelpConfiguration>(program.configureHelp());530531// copyInheritedSettingsReformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 532–534why, one step back532expectType<commander.Command>(533 program.copyInheritedSettings(new commander.Command()),534);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 535–545why, one step back535536// showHelpAfterError537expectType<commander.Command>(program.showHelpAfterError());538expectType<commander.Command>(program.showHelpAfterError(true));539expectType<commander.Command>(program.showHelpAfterError('See --help'));540541// showSuggestionAfterError542expectType<commander.Command>(program.showSuggestionAfterError());543expectType<commander.Command>(program.showSuggestionAfterError(false));544545// configureOutputReformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 546why, one step back546expectType<commander.Command>(program.configureOutput({}));Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 547–548why, one step back547expectType<commander.OutputConfiguration>(program.configureOutput());548Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 549–559why, one step back549expectType<commander.Command>(550 program.configureOutput({551 writeOut: (str: string) => {552 console.log(str);553 },554 writeErr: (str: string) => {555 console.error(str);556 },557 outputError: (str: string, write: (str: string) => void) => {558 write(str);559 },Support color ansi code sequences in custom help (#2251)John Geebefore adoption5629947
lines 560–566why, one step back560561 getOutHelpWidth: () => 80,562 getErrHelpWidth: () => 80,563564 getOutHasColors: () => true,565 getErrHasColors: () => true,566 stripColor: (str) => str,Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 567–568why, one step back567 }),568);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 569–575why, one step back569570// Help571const helper = new commander.Help();572const helperCommand = new commander.Command();573const helperOption = new commander.Option('-a, --all');574const helperArgument = new commander.Argument('<file>');575Support color ansi code sequences in custom help (#2251)John Geebefore adoption5629947
lines 576–578why, one step back576helper.prepareContext({});577helper.prepareContext({ helpWidth: 120, error: true, outputHasColors: false });578Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 579why, one step back579expectType<number | undefined>(helper.helpWidth);Support color ansi code sequences in custom help (#2251)John Geebefore adoption5629947
line 580why, one step back580expectType<number>(helper.minWidthToWrap);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 581–582why, one step back581expectType<boolean>(helper.sortSubcommands);582expectType<boolean>(helper.sortOptions);Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631
line 583why, one step back583expectType<boolean>(helper.showGlobalOptions);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 584–595why, one step back584585expectType<string>(helper.subcommandTerm(helperCommand));586expectType<string>(helper.commandUsage(helperCommand));587expectType<string>(helper.commandDescription(helperCommand));588expectType<string>(helper.subcommandDescription(helperCommand));589expectType<string>(helper.optionTerm(helperOption));590expectType<string>(helper.optionDescription(helperOption));591expectType<string>(helper.argumentTerm(helperArgument));592expectType<string>(helper.argumentDescription(helperArgument));593594expectType<commander.Command[]>(helper.visibleCommands(helperCommand));595expectType<commander.Option[]>(helper.visibleOptions(helperCommand));Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631
line 596why, one step back596expectType<commander.Option[]>(helper.visibleGlobalOptions(helperCommand));Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 597–600why, one step back597expectType<commander.Argument[]>(helper.visibleArguments(helperCommand));598599expectType<number>(helper.longestSubcommandTermLength(helperCommand, helper));600expectType<number>(helper.longestOptionTermLength(helperCommand, helper));Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631
line 601why, one step back601expectType<number>(helper.longestGlobalOptionTermLength(helperCommand, helper));Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 602–604why, one step back602expectType<number>(helper.longestArgumentTermLength(helperCommand, helper));603expectType<number>(helper.padWidth(helperCommand, helper));604Support color ansi code sequences in custom help (#2251)John Geebefore adoption5629947
lines 605–611why, one step back605expectType<number>(helper.displayWidth('some string'));606expectType<string>(helper.boxWrap('a b c', 50));607expectType<string>(608 helper.formatItem('--example', 12, 'example description', helper),609);610expectType<boolean>(helper.preformatted('a\nb c'));611Add typings for helpGroup support (#2367)John Geebefore adoptiondd7edf4
lines 612–645why, one step back612{613 const formattedItems = [614 '--example example description',615 '--example2 example2 description',616 ];617 expectType<string[]>(618 helper.formatItemList('Options', formattedItems, helper),619 );620}621622{623 const unsortedOptions = [new commander.Option('-a, --all')];624 const sortedOptions = unsortedOptions;625 const groupsItemsOptionHeading = (option: commander.Option) =>626 option.helpGroupHeading ?? 'Options:';627 expectType<Map<string, commander.Option[]>>(628 helper.groupItems(unsortedOptions, sortedOptions, groupsItemsOptionHeading),629 );630}631632{633 const unsortedCommands = [new commander.Command('foo')];634 const sortedCommands = unsortedCommands;635 const groupsItemsCommandHeading = (cmd: commander.Command) =>636 cmd.helpGroup() ?? 'Commands:';637 expectType<Map<string, commander.Command[]>>(638 helper.groupItems(639 unsortedCommands,640 sortedCommands,641 groupsItemsCommandHeading,642 ),643 );644}645Support color ansi code sequences in custom help (#2251)John Geebefore adoption5629947
lines 646–651why, one step back646expectType<string>(helper.styleTitle('Usage:'));647648expectType<string>(helper.styleUsage('foo [options] <file>'));649expectType<string>(helper.styleCommandText('foo'));650651expectType<string>(helper.styleCommandDescription('description'));Split styleItemDescription into option/subcommand/argument (#2283)John Geebefore adoption437e4e3
lines 652–654why, one step back652expectType<string>(helper.styleOptionDescription('description'));653expectType<string>(helper.styleSubcommandDescription('description'));654expectType<string>(helper.styleArgumentDescription('description'));Support color ansi code sequences in custom help (#2251)John Geebefore adoption5629947
lines 655–663why, one step back655expectType<string>(helper.styleDescriptionText('description'));656657expectType<string>(helper.styleOptionTerm('-a, --all'));658expectType<string>(helper.styleSubcommandTerm('bar [options]'));659expectType<string>(helper.styleArgumentTerm('<file>'));660661expectType<string>(helper.styleOptionText('-a, --all'));662expectType<string>(helper.styleSubcommandText('bar'));663expectType<string>(helper.styleArgumentText('<file>'));Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 664–666why, one step back664665expectType<string>(helper.formatHelp(helperCommand, helper));666Add more Option and Argument properties to typings (#2019)John Geebefore adoption744ee3f
line 667why, one step back667// Option propertiesAdd copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 668why, one step back668const baseOption = new commander.Option('-f,--foo', 'foo description');Add more Option and Argument properties to typings (#2019)John Geebefore adoption744ee3f
lines 669–677why, one step back669expectType<string>(baseOption.flags);670expectType<string>(baseOption.description);671expectType<boolean>(baseOption.required);672expectType<boolean>(baseOption.optional);673expectType<boolean>(baseOption.variadic);674expectType<boolean>(baseOption.mandatory);675expectType<string | undefined>(baseOption.short);676expectType<string | undefined>(baseOption.long);677expectType<boolean>(baseOption.negate);ESLint changes preparing for Prettier (#2153)John Geebefore adoption6fc933e
line 678why, one step back678// eslint-disable-next-line @typescript-eslint/no-explicit-anyAdd more Option and Argument properties to typings (#2019)John Geebefore adoption744ee3f
lines 679–684why, one step back679expectType<any>(baseOption.defaultValue);680expectType<string | undefined>(baseOption.defaultValueDescription);681expectType<unknown>(baseOption.presetArg);682expectType<string | undefined>(baseOption.envVar);683expectType<boolean>(baseOption.hidden);684expectType<string[] | undefined>(baseOption.argChoices);Add typings for helpGroup support (#2367)John Geebefore adoptiondd7edf4
line 685why, one step back685expectType<string | undefined>(baseOption.helpGroupHeading);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 686why, one step back686Add more Option and Argument properties to typings (#2019)John Geebefore adoption744ee3f
lines 687–688why, one step back687// Option methods688Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 689–700why, one step back689// default690expectType<commander.Option>(baseOption.default(3));691expectType<commander.Option>(baseOption.default(60, 'one minute'));692693// preset694expectType<commander.Option>(baseOption.preset(123));695expectType<commander.Option>(baseOption.preset('abc'));696697// env698expectType<commander.Option>(baseOption.env('PORT'));699700// argParserReformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 701–708why, one step back701expectType<commander.Option>(702 baseOption.argParser((value: string) => parseInt(value)),703);704expectType<commander.Option>(705 baseOption.argParser((value: string, previous: string[]) => {706 return previous.concat(value);707 }),708);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 709–727why, one step back709710// makeOptionMandatory711expectType<commander.Option>(baseOption.makeOptionMandatory());712expectType<commander.Option>(baseOption.makeOptionMandatory(true));713714// hideHelp715expectType<commander.Option>(baseOption.hideHelp());716expectType<commander.Option>(baseOption.hideHelp(true));717expectType<commander.Option>(baseOption.hideHelp(false));718719// choices720expectType<commander.Option>(baseOption.choices(['a', 'b']));721expectType<commander.Option>(baseOption.choices(['a', 'b'] as const));722723// conflicts724expectType<commander.Option>(baseOption.conflicts('a'));725expectType<commander.Option>(baseOption.conflicts(['a', 'b']));726727// impliesReformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 728–730why, one step back728expectType<commander.Option>(729 baseOption.implies({ option: 'VALUE', colour: false }),730);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 731–736why, one step back731732// name733expectType<string>(baseOption.name());734735// attributeName736expectType<string>(baseOption.attributeName());Add typings for helpGroup support (#2367)John Geebefore adoptiondd7edf4
lines 737–741why, one step back737738// helpGroup739expectType<commander.Option>(baseOption.helpGroup('My Group'));740// @ts-expect-error: Option helpGroup() can not be used as a getter.741baseOption.helpGroup();Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 742–750why, one step back742743// isBoolean744expectType<boolean>(baseOption.isBoolean());745746// Argument properties747const baseArgument = new commander.Argument('<foo');748expectType<string>(baseArgument.description);749expectType<boolean>(baseArgument.required);750expectType<boolean>(baseArgument.variadic);ESLint changes preparing for Prettier (#2153)John Geebefore adoption6fc933e
line 751why, one step back751// eslint-disable-next-line @typescript-eslint/no-explicit-anyAdd more Option and Argument properties to typings (#2019)John Geebefore adoption744ee3f
lines 752–754why, one step back752expectType<any>(baseArgument.defaultValue);753expectType<string | undefined>(baseArgument.defaultValueDescription);754expectType<string[] | undefined>(baseArgument.argChoices);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 755–765why, one step back755756// Argument methods757758// name759expectType<string>(baseArgument.name());760761// default762expectType<commander.Argument>(baseArgument.default(3));763expectType<commander.Argument>(baseArgument.default(60, 'one minute'));764765// argParserReformat code with Prettier (#2180)John Geebefore adoption1bdc749
lines 766–773why, one step back766expectType<commander.Argument>(767 baseArgument.argParser((value: string) => parseInt(value)),768);769expectType<commander.Argument>(770 baseArgument.argParser((value: string, previous: string[]) => {771 return previous.concat(value);772 }),773);Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 774–787why, one step back774775// choices776expectType<commander.Argument>(baseArgument.choices(['a', 'b']));777expectType<commander.Argument>(baseArgument.choices(['a', 'b'] as const));778779// argRequired780expectType<commander.Argument>(baseArgument.argRequired());781782// argOptional783expectType<commander.Argument>(baseArgument.argOptional());784785// createArgument786expectType<commander.Argument>(program.createArgument('<name>'));787expectType<commander.Argument>(program.createArgument('<name>', 'description'));