diff launch @ 25:e93e5e746cc5 draft header-includes

Preliminary debugging, still not fully tested.
author David Barts <n5jrn@me.com>
date Sun, 26 May 2019 11:43:48 -0700
parents e88ab99914cf
children ce67eac10fc7
line wrap: on
line diff
--- a/launch	Wed May 22 07:47:16 2019 -0700
+++ b/launch	Sun May 26 11:43:48 2019 -0700
@@ -18,13 +18,16 @@
 parser = ArgumentParser(prog=sys.argv[0], usage="%(prog)s [options] [directory [path]]")
 opt = parser.add_argument
 opt("-b", "--bind", default="localhost", help="address to bind to")
+opt("-d", "--debug", action="store_true", help="enable debug mode")
+opt("-f", "--force", action="store_true", help="do not abort on errors")
 opt("-p", "--port", default=8080, help="port to listen on")
 opt("directory", default=".", help="directory to serve", nargs='?')
 opt("path", default="/", help="URL path to serve", nargs='?')
 args = parser.parse_args(sys.argv[1:])
-app, errors = launch(fsroot=args.directory, urlroot=args.path)
+app, errors = launch(fsroot=args.directory, urlroot=args.path, debug=args.debug)
 if errors:
-    sys.stderr.write("{0}: {1} error{2} detected, aborting\n".format(
-        MYNAME, errors, "" if errors == 1 else "s"))
-    sys.exit(1)
+    action = "continuing" if args.force else "aborting"
+    sys.stderr.write("{0}: {1} error{2} detected, {3}\n".format(
+        MYNAME, errors, "" if errors == 1 else "s", action))
+    if not args.force: sys.exit(1)
 app.run(host=args.bind, port=args.port)