summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-09-15 14:14:49 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2019-09-15 14:14:49 -0400
commit55c9e12635c9988e25dc687754486721982a7b7f (patch)
tree1d9035fff1807f095af63eb5dc5119f7744c502d /cmd2/cmd2.py
parent3709be461b1d22ed934218b3ba1c3a335922a156 (diff)
downloadcmd2-git-55c9e12635c9988e25dc687754486721982a7b7f.tar.gz
Modified get_names() method to allow dynamically adding do_* commands to instances at runtime
Diffstat (limited to 'cmd2/cmd2.py')
-rwxr-xr-xcmd2/cmd2.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index a0a49a51..610ec897 100755
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -1596,6 +1596,10 @@ class Cmd(cmd.Cmd):
tokens, _ = self.tokens_for_completion(line, begidx, endidx)
return completer.complete_command(tokens, text, line, begidx, endidx)
+ def get_names(self):
+ """Return an alphabetized list of names comprising the attributes of the cmd2 class instance."""
+ return dir(self)
+
def get_all_commands(self) -> List[str]:
"""Return a list of all commands"""
return [name[len(COMMAND_FUNC_PREFIX):] for name in self.get_names()