-
Notifications
You must be signed in to change notification settings - Fork 57
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
Filter nested commands #133
base: master
Are you sure you want to change the base?
Filter nested commands #133
Conversation
Those test failures look real. I do wonder if this is really the best way to do this though, and I could envision things getting out of hand relatively quickly. I'm assuming most people are not going more than 3-4 levels deep. This being the case, couldn't you simply document the top level command with |
There's some prior art for this at #109, which I really need to review. |
You are right, unfortunately the actions log does not show what exactly failed. I locally got ruff/mypy failures and was worried how they could be caused by my changes, but then I checked the master commit (before mine) and they happened there already. I have not yet looked into how to fix them.
|
The mypy failures are fixed on master now. The tests failures are another matter though 😄 |
1d310c9
to
059302f
Compare
Indeed! And it was a tricky one! The single test alone passes, but when all tests are run together, one fails. That is because sphinx-click's |
Summary
The
commands
option currently allows to filter commands only at the first nesting level. When CLIs have deeper level of subcommands there is no way to filter or order them apart from writing a directive for each subcommand.This change passes the
commands
option to nested commands. As previously, if a command name at the CLI's top level occurs in the option, it is not documented. If a command name at any deeper level occurs in the option, it is now also excluded.Tasks
reno
)tox
)Further details
The filtering option does not distinguish the level of commands. This keeps the code and interface simple, but it could lead to a collision if a subcommand has the same name as a command but the user wants to filter only at a certain level. An alternative would be to provide full commands to filter, for example
(or with another delimiter like
command1.subcommand1
)I considered adding a unit test in
CommandFilterTestCase
. However all those tests testext._format_command
which does not include nested commands at deeper levels (nested=full
). For full nested commands, it is called several times byClickDirective._generate_nodes
.So I extended the existing full test case with the
:commands:
option.If there is a better way to test string formatting of nested=full, or if you prefer to keep the existing full test unchanged and add a separate one with commands filtering, I am happy to change that.