X-Git-Url: http://git.tremily.us/?p=hooke.git;a=blobdiff_plain;f=hooke%2Fhooke.py;h=54f0f0fb695b7ec734f0ee91ff7d5d526b5d8f78;hp=52834df7ab77a607c27c9e410fa3027457b9c238;hb=17615570c14dd0b6202d73f6e6ec24d70040dac8;hpb=fbbd22d3c9cd1ee9b6a1324bbdaf9ce4f330721a diff --git a/hooke/hooke.py b/hooke/hooke.py index 52834df..54f0f0f 100644 --- a/hooke/hooke.py +++ b/hooke/hooke.py @@ -182,6 +182,10 @@ def main(): '-c', '--command', dest='commands', metavar='COMMAND', action='append', default=[], help='Add a command line Hooke command to run.') + p.add_option( + '--command-no-exit', dest='command_exit', + action='store_false', default=True, + help="Don't exit after running a script or commands.") options,arguments = p.parse_args() if len(arguments) > 0: print >> sys.stderr, 'More than 0 arguments to %s: %s' \ @@ -196,15 +200,15 @@ def main(): print version() sys.exit(0) if options.script != None: - f = open(os.path.expanduser(options.script), 'r') - options.commands.extend(f.readlines()) - f.close + with open(os.path.expanduser(options.script), 'r') as f: + options.commands.extend(f.readlines()) if len(options.commands) > 0: try: hooke = runner.run_lines(hooke, options.commands) finally: - hooke.close() - sys.exit(0) + if options.command_exit == True: + hooke.close() + sys.exit(0) try: hooke = runner.run(hooke)