-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 #1832
Add getOptionValueSourceWithGlobals #1832
Conversation
|
||
getOptionValueSourceWithGlobals(key) { | ||
// global overwrites local, like optsWithGlobals | ||
let source; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reference :
You can also write the following using findLast
.
return getCommandAndParents(this)
.findLast((cmd) => cmd.getOptionValueSource(key) !== undefined)
.getOptionValueSource(key);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use Node.js 18 or later.
My apologies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started out planning to target Commander v10.x just so I could use ??
, but switched to old-school Node 12 compatible code for now. Eventually!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Released with Commander v9.5.0 |
Pull Request
Problem
We added
.optWithGlobals()
to make working with globals easier. And.getOptionValueSource()
for more complex programs. But how do you get the option value source including globals?See #1713
Solution
Added
.getOptionValueSourceWithGlobals()
.Sticking with the obvious and long name for what is probably a seldom used routine. Not planning to add to README.
ChangeLog
.getOptionValueSourceWithGlobals()