Skip to content

Added handling hidden parameter in commands. #9

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

Merged
merged 2 commits into from
Mar 3, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion click_command_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ def _build_command_tree(click_command):

if isinstance(click_command, click.core.Group):
for _, cmd in click_command.commands.items():
wrapper.children.append(_build_command_tree(cmd))
if not cmd.hidden:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the hidden attribute was added in v7, and I would like to keep this library as backwards compatible as possible. Could this also handle the case where this attribute is not there?

Suggested change
if not cmd.hidden:
if not getattr(cmd, "hidden", False):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure,
the offered solution was just proof of concept. Thank you for reply

wrapper.children.append(_build_command_tree(cmd))

return wrapper

Expand Down