UNPKG

1.5 kBJavaScriptView Raw
1#!/usr/bin/env node --harmony
2/**
3 * This executable will take care of capturing user input,
4 * passing data on to the domo lib and informing user of results.
5 * First it will check for supported Node versions.
6 *
7 */
8
9var path = require('path');
10var program = require('commander');
11var _ = require('lodash');
12var glob = require('glob');
13var verifyNodeVersion = require('../util/verifyNodeVersion');
14verifyNodeVersion();
15require('../polyfills/endswith');
16
17var cliVersion = require(path.resolve(__dirname + '/../package.json')).version;
18
19program
20 .version(cliVersion, '-v, --version')
21 .option('-w, --watch', '[DEPRECATED] publish Custom App design every time a file changes')
22 .option('-vb, --verbose', 'log more details including XHR responses, useful for troubleshooting')
23 .option('-m, --manifest [type]', 'use a specific manifest file');
24
25// import all commands
26glob
27 .sync(path.resolve(__dirname + "/../commands/*.js"))
28 .forEach(function(command){
29 require(command)(program);
30 });
31
32if (!process.argv.slice(2).length) {
33 program.help();
34} else {
35 program.parse(process.argv);
36
37 var has_command = false;
38
39 if (!program.args) {
40 program.args = [];
41 }
42
43 for (var i = 0, len = program.args.length; i < len; i++) {
44 if (program.args[i] instanceof program.Command) {
45 has_command = true;
46 break;
47 }
48 }
49
50 if (!has_command) {
51 console.log(' Invalid option "%s"', program.args.join(' '));
52 program.help();
53 }
54}