UNPKG

1.27 kBJavaScriptView Raw
1#!/usr/bin/env node
2
3'use strict';
4
5var
6 program = require('commander'),
7 commands = require('./lib/commands'),
8 options = require('./lib/options'),
9 updateNotifier = require('update-notifier'),
10 pkg = require('./package.json'),
11 version = pkg.version;
12
13program
14 .version(version)
15 .option('-l, --listen <n>', 'The port to listen on', 1337)
16 .option('-t, --target <n>', 'The port to loopback to', 9000)
17 .option('-T, --hostname <hostname>', 'The hostname to loopback to')
18 .option('-p, --proxy <hostname>', 'The hostname to proxy to')
19 .option('-v, --verbose', 'Enable verbose logging')
20 .option('-m, --mode <mode>', 'Proxy mode (labs, portal, or mixed)', 'labs')
21 .option('-s, --static <path>', 'Path to serve up static assets', './');
22
23program
24 .command('configure')
25 .description('Configures proxy options')
26 .action(commands.configure);
27
28program
29 .command('default')
30 .description('Start proxy server')
31 .action(commands._default);
32
33program.parse(process.argv);
34options.mixin(program);
35
36if (!program.args.length) {
37 // Not sure why commander doesn't handle this case...
38 commands._default();
39}
40
41updateNotifier({
42 packageName: pkg.name,
43 packageVersion: pkg.version
44}).notify({
45 defer: false
46});