summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-12-02 17:11:07 -0500
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-12-02 17:11:07 -0500
commit6d61eed050f94313540af8c73e34d10dde9d80f9 (patch)
tree9140e5f0a80769b7223a0e59e9854c7044deb89c /cmd2/cmd2.py
parentee735ed2a5a9e8d6d6fa6827a698c9d5630f0029 (diff)
downloadcmd2-git-6d61eed050f94313540af8c73e34d10dde9d80f9.tar.gz
Gave names to parser variables for a few commands so developers overriding these commands can use the parsers
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r--cmd2/cmd2.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index d2ab6bd3..fe31df41 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -2714,7 +2714,8 @@ class Cmd(cmd.Cmd):
command = ''
self.stdout.write("\n")
- @with_argparser(DEFAULT_ARGUMENT_PARSER(description="List available shortcuts"))
+ shortcuts_parser = DEFAULT_ARGUMENT_PARSER(description="List available shortcuts")
+ @with_argparser(shortcuts_parser)
def do_shortcuts(self, _: argparse.Namespace) -> None:
"""List available shortcuts"""
# Sort the shortcut tuples by name
@@ -2722,13 +2723,15 @@ class Cmd(cmd.Cmd):
result = "\n".join('{}: {}'.format(sc[0], sc[1]) for sc in sorted_shortcuts)
self.poutput("Shortcuts for other commands:\n{}".format(result))
- @with_argparser(DEFAULT_ARGUMENT_PARSER(epilog=INTERNAL_COMMAND_EPILOG))
+ eof_parser = DEFAULT_ARGUMENT_PARSER(description="Called when <Ctrl>-D is pressed", epilog=INTERNAL_COMMAND_EPILOG)
+ @with_argparser(eof_parser)
def do_eof(self, _: argparse.Namespace) -> bool:
"""Called when <Ctrl>-D is pressed"""
# Return True to stop the command loop
return True
- @with_argparser(DEFAULT_ARGUMENT_PARSER(description="Exit this application"))
+ quit_parser = DEFAULT_ARGUMENT_PARSER(description="Exit this application")
+ @with_argparser(quit_parser)
def do_quit(self, _: argparse.Namespace) -> bool:
"""Exit this application"""
# Return True to stop the command loop
@@ -3208,7 +3211,8 @@ class Cmd(cmd.Cmd):
# Only include the do_ipy() method if IPython is available on the system
if ipython_available: # pragma: no cover
- @with_argparser(DEFAULT_ARGUMENT_PARSER(description="Enter an interactive IPython shell"))
+ ipython_parser = DEFAULT_ARGUMENT_PARSER(description="Enter an interactive IPython shell")
+ @with_argparser(ipython_parser)
def do_ipy(self, _: argparse.Namespace) -> None:
"""Enter an interactive IPython shell"""
from .py_bridge import PyBridge