-
-
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 support for getting merged options including globals #1671
Add support for getting merged options including globals #1671
Conversation
Oh, BTW, why wouldn't |
Option 2 in the poll was a configuration to always include the globals in the options, but it didn't get a lot of likes. |
Yeah i c, in that case you had to call that |
Yes. Commander has some routines where the boolean arg is optional because the method name is clear about what will happen:
I don't like adding a plain boolean parameter which has no obvious meaning, like say:
Adding an options parameter makes effect clearer by naming the value, especially when not commonly used, and also allows future expansion.
|
Yeah, plain boolean is definitely no go. However speaking |
Yes I agree Using a separate method would look like:
Do you like that better? (Or are you now thinking option 2 is better!?) |
Yeah, |
Switched to |
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.
That is great. Looking forward to see it pushed in the next release 🔥
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.
LGTM!
|
Commander v9 has been released. |
Pull Request
Problem
Currently no direct support for getting merged options including globals. The work-around is to access the global options on the program or command parent.
This was the second most popular enhancement in poll #1551 (comment)
Related issues: #243 #476 (comment) #1024 #1229
Previous consideration by me: #1229 (comment) #1155 #1478
Solution
Add mergeOptions parameter to `.opts()`.
Add
command.optsWithGlobals()
.Example Usage
ChangeLog
.optsWithGlobals()
to return merged local and global options