Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getOptionValueSourceWithGlobals #18

Merged
merged 1 commit into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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