1 | #!/usr/bin/env node
|
2 |
|
3 | 'use strict';
|
4 |
|
5 | var
|
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 |
|
13 | program
|
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 |
|
23 | program
|
24 | .command('configure')
|
25 | .description('Configures proxy options')
|
26 | .action(commands.configure);
|
27 |
|
28 | program
|
29 | .command('default')
|
30 | .description('Start proxy server')
|
31 | .action(commands._default);
|
32 |
|
33 | program.parse(process.argv);
|
34 | options.mixin(program);
|
35 |
|
36 | if (!program.args.length) {
|
37 |
|
38 | commands._default();
|
39 | }
|
40 |
|
41 | updateNotifier({
|
42 | packageName: pkg.name,
|
43 | packageVersion: pkg.version
|
44 | }).notify({
|
45 | defer: false
|
46 | });
|