-
Notifications
You must be signed in to change notification settings - Fork 3
/
cli.js
58 lines (52 loc) · 1.1 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
#!/usr/bin/env node
var sys = require("sys");
var no_de = require("./no.de");
var argv = process.argv.slice(2);
var command = argv.shift();
var method = command;
var params = [];
switch(command) {
case "sshkeys":
if(argv.length) {
method = method + "_" + argv.shift().substr(2);
params = argv;
}
break;
case "config":
method = method + "_" + argv.shift().substr(2);
params = argv;
break;
case "coupons":
if(argv.length) {
method = method + "_" + argv.shift().substr(2);
}
break;
case "help":
if(argv.length) {
params = argv.shift();
}
break;
case "bind":
params = argv;
break;
case "create":
if(argv.length) {
if(argv[0].substr(2) == "bind") {
argv.shift();
params = argv;
params.push(true);
} else {
params = argv;
params.push(false);
}
} else {
sys.puts("Missing arguments to create.");
method = null;
}
break;
}
if(method && no_de.commands.hasOwnProperty(method) && no_de.commands[method].call) {
no_de.commands[method].apply(no_de, params);
} else {
sys.puts("invalid or missing command: `no.de help` for a list of commands");
}