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

WIP: Add globalOpts() #1478

Closed
wants to merge 2 commits into from
Closed

Conversation

shadowspawn
Copy link
Collaborator

@shadowspawn shadowspawn commented Feb 28, 2021

Pull Request

Problem

People wonder how to get the global options from a subcommand.

The current approaches are calling say program.opts() if have a variable available for the program, or calling cmd.parent.opts() from in the action handler. And looping if there are multiple levels of subcommands with options.

Related: #243 #476 #1024 (comment) #1155 #1229

The main expected use of the parent property is to get global options: #1475

Solution

Add .globalOpts() which returns the combined global options from global/parent commands.

I did consider adding a parameter to .opts() to return combined local and global options, but I think explicit routine is simpler. Likewise, I wondered adding a configuration option to have the combined options passed into the action handler, but again explicit routine is simpler to understand.

ChangeLog

To Do

  • typings
  • tests
  • README
  • CHANGELOG

@shadowspawn shadowspawn changed the base branch from master to develop February 28, 2021 03:12
@shadowspawn
Copy link
Collaborator Author

Not sure what people actually want with global options. Closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant