Repository navigation
Expand file tree
/
Copy pathcli.js
More file actions
62 lines (53 loc) · 1.5 KB
/
Copy pathcli.js
File metadata and controls
62 lines (53 loc) · 1.5 KB
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
#!/usr/bin/env node
'use strict';
const meow = require('meow');
const shelf = require('.');
const cli = meow(`
Usage
$ shelf [input]
Options
--foo Lorem ipsum [Default: false]
Examples
$ shelf adduser xo
Finished setting up user xo.
$ shelf adddomain xo example.com
Finished setting up domain example.com.
Container running.
done
`, {
boolean: [
'init'
]
});
const command = cli.input[0];
const flags = cli.flags;
if (flags.init === true) {
shelf.init().then(msg => console.log(msg)).catch(err => console.error(err.message));
} else if (command === 'adddomain' || command === 'deldomain') {
const username = cli.input[1];
const domain = cli.input[2];
shelf.adddomain({
username,
domain
}).then(msg => console.log(msg)).catch(err => console.error(err.message));
shelf.createContainer({
user: {
_id: 100,
username
},
domain
}).then(msg => console.log(msg)).catch(err => console.error(err.message));
} else if (command === 'adduser' || command === 'deluser') {
const username = cli.input[1];
shelf.adduser({
username
}).then(msg => console.log(msg)).catch(err => console.error(err.message));
// @NOTE: Check ~/code/shelf-old for code
// 1. Create/Delete user account
// 2. Add/Remove containers linked to their account
// 3. Add/Remove vhost file from Caddy
// 4. Reload Caddy
// 5. Add/Remove their sftp account
} else {
cli.showHelp();
}