diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-08-21 22:56:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-21 22:56:05 -0400 |
commit | 3234833c462bd0817f55b8a8145c99347765e77b (patch) | |
tree | c2790e1b3f008a0968a1d00f34ccefe26c2e2102 /cmd2/cmd2.py | |
parent | 551f635ae14b814be6855e9ac8198216ad3a089c (diff) | |
parent | 6d74e51aeb769033f1ce8657b8570fb2e167ed8a (diff) | |
download | cmd2-git-3234833c462bd0817f55b8a8145c99347765e77b.tar.gz |
Merge pull request #501 from python-cmd2/all_commands
Make sure get_all_commands() returns functions
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index 94b75e5f..f39ee2ee 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -1553,7 +1553,8 @@ class Cmd(cmd.Cmd): def get_all_commands(self) -> List[str]: """Returns a list of all commands.""" - return [cur_name[3:] for cur_name in self.get_names() if cur_name.startswith('do_')] + return [name[3:] for name in self.get_names() + if name.startswith('do_') and isinstance(getattr(self, name), Callable)] def get_visible_commands(self) -> List[str]: """Returns a list of commands that have not been hidden.""" @@ -1568,7 +1569,8 @@ class Cmd(cmd.Cmd): def get_help_topics(self) -> List[str]: """ Returns a list of help topics """ - return [name[5:] for name in self.get_names() if name.startswith('help_')] + return [name[5:] for name in self.get_names() + if name.startswith('help_') and isinstance(getattr(self, name), Callable)] def complete_help(self, text: str, line: str, begidx: int, endidx: int) -> List[str]: """ @@ -2470,7 +2472,7 @@ Usage: Usage: unalias [-a] name [name ...] self._should_quit = True return self._STOP_AND_EXIT - def select(self, opts: Union[str, List[str], List[Tuple[str, Optional[str]]]], prompt: str='Your choice? ') -> str: + def select(self, opts: Union[str, List[str], List[Tuple[Any, Optional[str]]]], prompt: str='Your choice? ') -> str: """Presents a numbered menu to the user. Modelled after the bash shell's SELECT. Returns the item chosen. |