-
Notifications
You must be signed in to change notification settings - Fork 0
/
birdy.js
executable file
·58 lines (54 loc) · 1.61 KB
/
birdy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env node
var logger = require('loge');
var optimist = require('optimist');
var argvparser = optimist
.usage([
'Usage: birdy <command> [<options>]',
'',
' init [jquery==2.0.0] [backbone]',
' create package.json or add "staticDependencies" hash to it,',
' prefilled with the given packages',
'',
' install [jquery] [underscore==1.5.2]',
' fetch the packages specified in "staticDependencies" in your',
' package.json, as well as at the command line, and install them',
' into the specified folder.',
'',
' search [query]',
' list resources that birdy supports, filtering by query, if',
' specified',
].join('\n'))
.describe({
help: 'print this help message',
version: 'print birdy version and exit',
verbose: 'print extra output',
config: 'JSON config file with staticPattern and staticDependencies fields.',
pattern: 'naming scheme for local files - defaults to "static/{resource}/{file}"',
})
.boolean(['help', 'verbose', 'version'])
.default({
config: 'package.json',
})
.alias({
pattern: 'staticPattern',
});
var argv = argvparser.argv;
logger.level = argv.verbose ? 'debug' : 'info';
if (argv.help) {
argvparser.showHelp();
}
else if (argv.version) {
// read birdy's own package.json for the current version
console.log(require('../package').version);
}
else {
var commands = require('./birdy-commands');
argv = argvparser.check(function(argv) {
var command = argv._[0];
if (commands[command] === undefined) {
throw new Error('You must specify a valid command.');
}
}).argv;
var command = argv._[0];
commands[command](argv);
}