Skip to content

getOptionValueSource() in a command context returns undefined for global options #1713

@sinedied

Description

@sinedied

Hello,

I need to distinguish in my code which options comes from the user (via CLI options), and which one are just the default values.
For that, I use getOptionValueSource() but I have an issue with that, as it always return undefined when trying to get the source of a global option in a command context.

I retrieve all options using command.optsWithGlobals(), but then command.getOptionValueSource() only works for command-level options, and if I use program.getOptionValueSource() it only works with global-level options.

Should I merge all options manually instead of using optsWithGlobals() to separate the two contexts when trying to determine the source of the options? It would seems a bit complicated for a simple use case.

Would you consider adding a getOptionValueSourceWithGlobals to match the behavior of optsWithGlobals, so that we could retrieve the option's source if it comes either from command or global level?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions