This repository has been archived by the owner on Mar 1, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcli.js
73 lines (57 loc) · 1.43 KB
/
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
'use strict';
var marmelada = require('./');
var minimist = require('minimist');
var multiline = require('multiline');
var defaults = {
boolean: [
'help',
'version'
],
alias: {
h: 'help',
v: 'version',
f: 'format',
t: 'total',
i: 'ignore'
}
};
var version = require('./package.json').version;
var help = multiline(function() {/*
Usage: marmelada [URL] [OPTIONS]
Randomly select people for FEMUG-SP's meetings.
Example:
marmelada http://sp.femug.com/t/femug-42-nasa --total 10
Options:
-v --version Display current software version.
-h --help Display help and usage details.
-f --format Output format.
-t --total Total spots available for the meeting (defaults to list size).
-i --ignore Ignore list (comma separated and case sensitive).
*/});
function run(argv) {
var url = argv._[0];
if(!url) {
exports.stderr.write('You must provide at least an URL');
exports.exitCode = 1;
return;
}
marmelada(url, argv);
}
exports.exitCode = 0;
exports.stdout = process.stdout;
exports.stderr = process.stderr;
exports.parse = function(options) {
return minimist(options, defaults);
};
exports.run = function(argv) {
exports.exitCode = 0;
if(argv.help) {
exports.stderr.write(help);
return;
}
if(argv.version) {
exports.stderr.write('marmelada v' + version + '\n');
return;
}
run(argv);
};