diff launch @ 37:ce67eac10fc7 draft header-includes

Allow global character encoding specification.
author David Barts <n5jrn@me.com>
date Tue, 28 May 2019 17:08:36 -0700
parents e93e5e746cc5
children df27cf08c093
line wrap: on
line diff
--- a/launch	Tue May 28 15:54:47 2019 -0700
+++ b/launch	Tue May 28 17:08:36 2019 -0700
@@ -7,7 +7,7 @@
 
 import os, sys
 from argparse import ArgumentParser
-from tincan import launch
+from tincan import launch, ENCODING
 
 # V a r i a b l e s
 
@@ -17,14 +17,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("-b", "--bind", default="localhost", help="address to bind to (default: localhost)")
 opt("-d", "--debug", action="store_true", help="enable debug mode")
+opt("-e", "--encoding", default=ENCODING, help="encoding to use (default {0})".format(ENCODING))
 opt("-f", "--force", action="store_true", help="do not abort on errors")
-opt("-p", "--port", default=8080, help="port to listen on")
+opt("-p", "--port", default=8080, help="port to listen on (default: 8080)")
 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, debug=args.debug)
+app, errors = launch(fsroot=args.directory, urlroot=args.path, debug=args.debug,
+    encoding=args.encoding)
 if errors:
     action = "continuing" if args.force else "aborting"
     sys.stderr.write("{0}: {1} error{2} detected, {3}\n".format(