Filter nested commands #133
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.