1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 | require('coffee-script/register')
|
5 |
|
6 | var path = require('path');
|
7 |
|
8 | var program = require('commander');
|
9 |
|
10 | var util = require('../lib/util');
|
11 | var config = require('../lib/config');
|
12 | var root = path.dirname(__dirname),
|
13 | version;
|
14 |
|
15 | try {
|
16 | version = require(path.join(root, 'package.json')).version;
|
17 | } catch (e) {
|
18 | version = '0.0.1';
|
19 | }
|
20 |
|
21 | config.load();
|
22 |
|
23 | program
|
24 | .version(version)
|
25 | .option('-v, --verbose', 'display verbose output', false)
|
26 | .usage('<command> [options]');
|
27 |
|
28 | util.walkSync(path.join(root, 'lib', 'commands'), ['.coffee'], function (file, folder) {
|
29 | var command = require(file);
|
30 |
|
31 | command(program);
|
32 | });
|
33 |
|
34 | program.parse(process.argv);
|
35 |
|
36 | if (process.argv.length < 3) {
|
37 | process.stdout.write(program.helpInformation());
|
38 | }
|
39 |
|
40 |
|
41 | process.on('exit', function () {
|
42 | config.write();
|
43 | });
|