Skip to content

Commit

Permalink
Add getOptionValueSourceWithGlobals (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowspawn committed Dec 19, 2022
1 parent c0a96ab commit 536ef60
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -775,11 +775,17 @@ export class CommanderError extends Error {
setOptionValueWithSource(key: string, value: unknown, source: OptionValueSource): this;

/**
* Retrieve option value source.
* Get source of option value.
*/
getOptionValueSource<K extends keyof Opts>(key: K): OptionValueSource | undefined;
getOptionValueSource(key: string): OptionValueSource | undefined;

/**
* Get source of option value. See also .optsWithGlobals().
*/
getOptionValueSourceWithGlobals<K extends keyof Opts>(key: K): OptionValueSource | undefined;
getOptionValueSourceWithGlobals(key: string): OptionValueSource | undefined;

/**
* Alter parsing of short flags with optional values.
*
Expand Down
3 changes: 3 additions & 0 deletions tests/commander.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ expectChainedCommand(program.setOptionValueWithSource('example', [], 'cli'));
// getOptionValueSource
expectType<commander.OptionValueSource | undefined>(program.getOptionValueSource('example'));

// getOptionValueSourceWithGlobals
expectType<commander.OptionValueSource | undefined>(program.getOptionValueSourceWithGlobals('example'));

// combineFlagAndOptionalValue
expectChainedCommand(program.combineFlagAndOptionalValue());
expectChainedCommand(program.combineFlagAndOptionalValue(false));
Expand Down

0 comments on commit 536ef60

Please sign in to comment.