#!/usr/bin/env node const path = require('path') const go = require('../index.js') const help = ` USAGE now-go -c -c, --config JS or JSON config file path -p, --port Port to listen on (default: 3000) -h, --help Show this help message -v, --version Show version EXAMPLE CONFIG JSON { "/home": "https://github.com/amio/now-go", "/": "Yet another tinyurl service", "*": "What are you looking for" } ` const args = require('minimist')(process.argv.slice(2), { alias: { 'p': 'port', 'c': 'config', 'v': 'version', 'h': 'help' }, default: { 'c': process.env.NOW_GO_CONFIG, 'p': 3000 } }) if (args.help) { console.log(help) process.exit() } if (args.version) { console.log(require('../package.json').version) process.exit() } if (args.config) { const config = require(path.resolve(process.cwd(), args.config)) const options = { port: parseInt(args.port) || 3000 } go(config, options) } else { console.log(help) process.exit(1) }