diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2019-12-03 00:10:37 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-03 00:10:37 -0500 |
commit | 7722be4df056674f55f333a90e8c31fd4099bf8a (patch) | |
tree | 9140e5f0a80769b7223a0e59e9854c7044deb89c /cmd2/cmd2.py | |
parent | ee735ed2a5a9e8d6d6fa6827a698c9d5630f0029 (diff) | |
parent | 6d61eed050f94313540af8c73e34d10dde9d80f9 (diff) | |
download | cmd2-git-7722be4df056674f55f333a90e8c31fd4099bf8a.tar.gz |
Merge pull request #825 from python-cmd2/parsers
Gave names to parser variables for a few commands
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r-- | cmd2/cmd2.py | 12 |
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 |