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

global options example: pass arguments to sub-subcommands too #1754

Closed
wants to merge 1 commit into from

Conversation

arve0
Copy link

@arve0 arve0 commented Jun 16, 2022

Problem

Was hard to understand why sub-subcommand did not get option, even though --help shows the option. I read the example, others will probably too. Expand it to also add options to sub-subcommands.

See issue #1753.

Solution

Added sub-subcommand to global-options example.

@shadowspawn
Copy link
Collaborator

Thanks for the suggestion, but I don't want repeated ("inherited") options in nested subcommands in this example file. That is a complex pattern with some drawbacks.

I wrote this example so that options are only added in "leaf" commands, so options are not repeated at different levels of the hierarchy. To keep the code simple I limited the subcommands to just one level deep.

Note the name of the Command subclass (MyRootCommand), and also the comment on line 6:

// The code in this example assumes there is just one level of subcommands.

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

2 participants