From 1cd0a38cac5482bdf274f42ffcdc41519a5362b1 Mon Sep 17 00:00:00 2001 From: Todd Leonhardt Date: Mon, 19 Mar 2018 19:29:06 -0400 Subject: Added a default signal handler for SIGINT (Ctrl-C) Added a default signal handler for SIGINT that does the following: - Terminates a pipe process if one exists - Raises a KeyboardInterrupt for other parts othe code to catch Also: - Changed the default value for quit_on_sigint to False - Modified the way the subcommand functions are called in subcommand.py (unrelated to rest of commit) --- examples/subcommands.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples/subcommands.py') diff --git a/examples/subcommands.py b/examples/subcommands.py index fa99f6b4..2a7e0afa 100755 --- a/examples/subcommands.py +++ b/examples/subcommands.py @@ -63,11 +63,11 @@ class SubcommandsExample(cmd2.Cmd): @with_argparser(base_parser) def do_base(self, args): """Base command help""" - try: + if args.func is not None: # Call whatever subcommand function was selected args.func(self, args) - except AttributeError: - # No subcommand was provided, so as called + else: + # No subcommand was provided, so call help self.do_help('base') # functools.partialmethod was added in Python 3.4 -- cgit v1.2.1