summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-09-25 19:14:29 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-09-25 19:14:29 -0400
commit2d38b72ba2203eb5cacbe0cb72cf7b8e27b5bb21 (patch)
treeda5ed281bb9d3e1b63c01b5aaba9f998cf2e4a6b /cmd2/cmd2.py
parent39e43d6329eb517ac58f95a8ca37e7e489d446cb (diff)
parent8b12ab9f01c5a2b08c72fd4d2e1aaa15b402ead4 (diff)
downloadcmd2-git-2d38b72ba2203eb5cacbe0cb72cf7b8e27b5bb21.tar.gz
Merge branch 'master' into alert_printer
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r--cmd2/cmd2.py13
1 files changed, 4 insertions, 9 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 00e113a9..765b19a2 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -1615,7 +1615,7 @@ class Cmd(cmd.Cmd):
try:
cmd_func = getattr(self, 'do_' + tokens[cmd_index])
parser = getattr(cmd_func, 'argparser')
- completer = AutoCompleter(parser)
+ completer = AutoCompleter(parser, cmd2_app=self)
matches = completer.complete_command_help(tokens[1:], text, line, begidx, endidx)
except AttributeError:
pass
@@ -2275,14 +2275,9 @@ class Cmd(cmd.Cmd):
# Check to see if this function was decorated with an argparse ArgumentParser
func = getattr(self, funcname)
if hasattr(func, 'argparser'):
- # Function has an argparser, so get help based on all the arguments in case there are sub-commands
- new_arglist = arglist[1:]
- new_arglist.append('-h')
-
- # Temporarily redirect all argparse output to both sys.stdout and sys.stderr to self.stdout
- with redirect_stdout(self.stdout):
- with redirect_stderr(self.stdout):
- func(new_arglist)
+ completer = AutoCompleter(getattr(func, 'argparser'), cmd2_app=self)
+
+ self.poutput(completer.format_help(arglist))
else:
# No special behavior needed, delegate to cmd base class do_help()
cmd.Cmd.do_help(self, funcname[3:])