diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-09-24 13:08:33 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-09-24 13:08:33 -0400 |
commit | 23f6c824de7c6981c9e06307caa667bcd7d542dc (patch) | |
tree | 038f76a2c641686b31a6131eeac27058e6aab0c9 /cmd2/cmd2.py | |
parent | 393b2426696cd7c2e19a93a1eee98d4978693481 (diff) | |
download | cmd2-git-23f6c824de7c6981c9e06307caa667bcd7d542dc.tar.gz |
Fixed bug introduced by get_names() looking at self instead of self.__class__.
Help functions for hidden and disabled commands were not being filtered out as help topics.
Diffstat (limited to 'cmd2/cmd2.py')
-rwxr-xr-x | cmd2/cmd2.py | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index d353af14..50d562b4 100755 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -1625,19 +1625,8 @@ class Cmd(cmd.Cmd): def get_visible_commands(self) -> List[str]: """Return a list of commands that have not been hidden or disabled""" - commands = self.get_all_commands() - - # Remove the hidden commands - for name in self.hidden_commands: - if name in commands: - commands.remove(name) - - # Remove the disabled commands - for name in self.disabled_commands: - if name in commands: - commands.remove(name) - - return commands + return [command for command in self.get_all_commands() + if command not in self.hidden_commands and command not in self.disabled_commands] def _get_alias_completion_items(self) -> List[CompletionItem]: """Return list of current alias names and values as CompletionItems""" @@ -1659,9 +1648,13 @@ class Cmd(cmd.Cmd): return list(visible_commands | alias_names | macro_names) def get_help_topics(self) -> List[str]: - """ Returns a list of help topics """ - return [name[len(HELP_FUNC_PREFIX):] for name in self.get_names() - if name.startswith(HELP_FUNC_PREFIX) and callable(getattr(self, name))] + """Return a list of help topics""" + all_topics = [name[len(HELP_FUNC_PREFIX):] for name in self.get_names() + if name.startswith(HELP_FUNC_PREFIX) and callable(getattr(self, name))] + + # Filter out hidden and disabled commands + return [topic for topic in all_topics + if topic not in self.hidden_commands and topic not in self.disabled_commands] # noinspection PyUnusedLocal def sigint_handler(self, signum: int, frame) -> None: |