Skip to content

Commit 7722be4

Browse files
authored
Merge pull request #825 from python-cmd2/parsers
Gave names to parser variables for a few commands
2 parents ee735ed + 6d61eed commit 7722be4

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

cmd2/cmd2.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,21 +2714,24 @@ def _print_topics(self, header: str, cmds: List[str], verbose: bool) -> None:
27142714
command = ''
27152715
self.stdout.write("\n")
27162716

2717-
@with_argparser(DEFAULT_ARGUMENT_PARSER(description="List available shortcuts"))
2717+
shortcuts_parser = DEFAULT_ARGUMENT_PARSER(description="List available shortcuts")
2718+
@with_argparser(shortcuts_parser)
27182719
def do_shortcuts(self, _: argparse.Namespace) -> None:
27192720
"""List available shortcuts"""
27202721
# Sort the shortcut tuples by name
27212722
sorted_shortcuts = sorted(self.statement_parser.shortcuts, key=lambda x: self.default_sort_key(x[0]))
27222723
result = "\n".join('{}: {}'.format(sc[0], sc[1]) for sc in sorted_shortcuts)
27232724
self.poutput("Shortcuts for other commands:\n{}".format(result))
27242725

2725-
@with_argparser(DEFAULT_ARGUMENT_PARSER(epilog=INTERNAL_COMMAND_EPILOG))
2726+
eof_parser = DEFAULT_ARGUMENT_PARSER(description="Called when <Ctrl>-D is pressed", epilog=INTERNAL_COMMAND_EPILOG)
2727+
@with_argparser(eof_parser)
27262728
def do_eof(self, _: argparse.Namespace) -> bool:
27272729
"""Called when <Ctrl>-D is pressed"""
27282730
# Return True to stop the command loop
27292731
return True
27302732

2731-
@with_argparser(DEFAULT_ARGUMENT_PARSER(description="Exit this application"))
2733+
quit_parser = DEFAULT_ARGUMENT_PARSER(description="Exit this application")
2734+
@with_argparser(quit_parser)
27322735
def do_quit(self, _: argparse.Namespace) -> bool:
27332736
"""Exit this application"""
27342737
# Return True to stop the command loop
@@ -3208,7 +3211,8 @@ def do_run_pyscript(self, args: argparse.Namespace) -> Optional[bool]:
32083211

32093212
# Only include the do_ipy() method if IPython is available on the system
32103213
if ipython_available: # pragma: no cover
3211-
@with_argparser(DEFAULT_ARGUMENT_PARSER(description="Enter an interactive IPython shell"))
3214+
ipython_parser = DEFAULT_ARGUMENT_PARSER(description="Enter an interactive IPython shell")
3215+
@with_argparser(ipython_parser)
32123216
def do_ipy(self, _: argparse.Namespace) -> None:
32133217
"""Enter an interactive IPython shell"""
32143218
from .py_bridge import PyBridge

0 commit comments

Comments
 (0)