diff options
Diffstat (limited to 'Lib/cmd.py')
-rw-r--r-- | Lib/cmd.py | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/Lib/cmd.py b/Lib/cmd.py index 10aa5acf4b..8fa7d019b5 100644 --- a/Lib/cmd.py +++ b/Lib/cmd.py @@ -84,7 +84,6 @@ class Cmd: sys.stdin and sys.stdout are used. """ - import sys if stdin is not None: self.stdin = stdin else: @@ -278,21 +277,18 @@ class Cmd: return None def get_names(self): - # Inheritance says we have to look in class and - # base classes; order is not important. - names = [] - classes = [self.__class__] - while classes: - aclass = classes.pop(0) - if aclass.__bases__: - classes = classes + list(aclass.__bases__) - names = names + dir(aclass) - return names + # This method used to pull in base class attributes + # at a time dir() didn't do it yet. + return dir(self.__class__) def complete_help(self, *args): - return self.completenames(*args) + commands = set(self.completenames(*args)) + topics = set(a[5:] for a in self.get_names() + if a.startswith('help_' + args[0])) + return list(commands | topics) def do_help(self, arg): + 'List available commands with "help" or detailed help with "help cmd".' if arg: # XXX check arg syntax try: |