diff --git a/lib/server.js b/lib/server.js index 631640b..c4668bf 100644 --- a/lib/server.js +++ b/lib/server.js @@ -23,12 +23,31 @@ colors.setTheme({ error: 'red' }); -// Default initialized options. -var options = { - key: fs.readFileSync(__dirname + '/../keys/key.pem'), - cert: fs.readFileSync(__dirname + '/../keys/crt.pem'), - port: 55073 -}; +// Parse command-line arguments. +var options = require('optimist') + .options({ + port: { + demand: true, + alias: 'p', + description: 'Listen port', + default: 55073 + }, + keyPath: { + demand: true, + alias: 'k', + description: 'SSL key path', + default: __dirname + '/../keys/key.pem', + }, + certPath: { + demand: true, + alias: 'c', + description: 'SSL certificate path', + default: __dirname + '/../keys/crt.pem', + } + }).argv; + +options.key = fs.readFileSync(options.keyPath); +options.cert = fs.readFileSync(options.certPath); // Shortens the given URL to given maxLen by inserting '...'. function shortenUrl(url, maxLen) { diff --git a/package.json b/package.json index f8d3054..2fda1fb 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "spdy": "~1.26.0", "colors": "~0.6.2", "memory-cache": "0.0.5", - "png": "~3.0.3" + "png": "~3.0.3", + "optimist": "~0.6.1" } }