UNPKG

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