Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions cmd2/cmd2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2714,21 +2714,24 @@ def _print_topics(self, header: str, cmds: List[str], verbose: bool) -> None:
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
sorted_shortcuts = sorted(self.statement_parser.shortcuts, key=lambda x: self.default_sort_key(x[0]))
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
Expand Down Expand Up @@ -3208,7 +3211,8 @@ def do_run_pyscript(self, args: argparse.Namespace) -> Optional[bool]:

# 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
Expand Down