-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsonglocator-cli.js
55 lines (48 loc) · 1.18 KB
/
songlocator-cli.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
//@ sourceMappingURL=songlocator-cli.map
// Generated by CoffeeScript 1.6.1
/*
Command line interface for SongLocator.
2013 (c) Andrey Popp <[email protected]>
*/
var ResolverSet, rankSearchResults, readFileSync, _ref;
readFileSync = require('fs').readFileSync;
_ref = require('songlocator-base'), ResolverSet = _ref.ResolverSet, rankSearchResults = _ref.rankSearchResults;
exports.readConfigSync = function(filename) {
if (filename == null) {
filename = './songlocator.json';
}
try {
return JSON.parse(readFileSync(filename));
} catch (e) {
return void 0;
}
};
exports.parseArguments = function(argv) {
var arg, args, opts;
if (argv == null) {
argv = process.argv;
}
argv = argv.splice(2);
args = [];
opts = {
config: void 0,
resolvers: [],
debug: false
};
while (argv.length > 0) {
arg = argv.shift();
if (arg === '-c' || arg === '--config') {
opts.config = argv.shift();
} else if (arg === '--debug') {
opts.debug = true;
} else if (arg.substring(0, 6) === '--use-') {
opts.resolvers.push(arg.substring(6));
} else {
args.push(arg);
}
}
return {
args: args,
opts: opts
};
};