summaryrefslogtreecommitdiff
path: root/examples/subcommands.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-03-19 19:29:06 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2018-03-19 19:29:06 -0400
commit1cd0a38cac5482bdf274f42ffcdc41519a5362b1 (patch)
tree72da4f9c380d77a2c2fd9cc91458f7eec2ecc824 /examples/subcommands.py
parent627360cfc71995af939569b2aee9dbc8141544d0 (diff)
downloadcmd2-git-1cd0a38cac5482bdf274f42ffcdc41519a5362b1.tar.gz
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)
Diffstat (limited to 'examples/subcommands.py')
-rwxr-xr-xexamples/subcommands.py6
1 files changed, 3 insertions, 3 deletions
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