Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / ibrik / lib / command.js
1 // Generated by CoffeeScript 1.8.0
2 (function() {
3   var COMMANDS, TAB, argv, c, command, fs, optimist, possibilities,
4     __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
5
6   fs = require('fs');
7
8   optimist = require('optimist');
9
10   COMMANDS = ['cover', 'report'];
11
12   TAB = '        ';
13
14   argv = optimist.usage("Usage: $0 subcommand\n=== subcommands ===\n" + TAB + (COMMANDS.join("\n" + TAB))).argv;
15
16   command = argv._[0];
17
18   if (command == null) {
19     optimist.showHelp();
20     process.exit(0);
21   }
22
23   if (__indexOf.call(COMMANDS, command) < 0) {
24     possibilities = (function() {
25       var _i, _len, _results;
26       _results = [];
27       for (_i = 0, _len = COMMANDS.length; _i < _len; _i++) {
28         c = COMMANDS[_i];
29         if (command === c.slice(0, command.length)) {
30           _results.push(c);
31         }
32       }
33       return _results;
34     })();
35     switch (possibilities.length) {
36       case 0:
37         console.error("Unrecognised command: `" + command + "`. Run `" + argv['$0'] + "` for help.");
38         process.exit(1);
39         break;
40       case 1:
41         command = possibilities[0];
42         break;
43       default:
44         console.error("Ambiguous command `" + command + "` matches `" + (possibilities.join('`, `')) + "`");
45         process.exit(1);
46     }
47   }
48
49   (require("./" + command))(argv, function(err) {
50     if (err) {
51       console.error(err);
52       process.exit(1);
53     }
54     return process.exit(0);
55   });
56
57 }).call(this);