Add CLI option for the server port.
This commit is contained in:
+3
-2
@@ -8,7 +8,8 @@ Usage:
|
|||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
-c, --config <cfgFile> Use the given config file (defaults to ./short-url.cfg.json)
|
-c, --config <cfgFile> Use the given config file (defaults to ./short_url.cfg.json)
|
||||||
|
--port <port> Bind the server to the given port (defaults to 80)
|
||||||
--debug Enable debug-level logging.
|
--debug Enable debug-level logging.
|
||||||
--trace Enable trace-level logging (takes precedence over --debug).
|
--trace Enable trace-level logging (takes precedence over --debug).
|
||||||
"""
|
"""
|
||||||
@@ -29,7 +30,7 @@ type
|
|||||||
proc loadConfig(args: Table[string, Value]): ShortUrlsConfig =
|
proc loadConfig(args: Table[string, Value]): ShortUrlsConfig =
|
||||||
let cfgFile =
|
let cfgFile =
|
||||||
if args["--config"]: $args["--config"]
|
if args["--config"]: $args["--config"]
|
||||||
else: findConfigFile("short-url.cfg.json")
|
else: findConfigFile("short_url.cfg.json")
|
||||||
|
|
||||||
result.cfg = initCombinedConfig(filename = cfgFile, docopt = args)
|
result.cfg = initCombinedConfig(filename = cfgFile, docopt = args)
|
||||||
result.port = parseInt(result.cfg.getVal("port", "80"))
|
result.port = parseInt(result.cfg.getVal("port", "80"))
|
||||||
|
|||||||
Reference in New Issue
Block a user