-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
65 lines (60 loc) · 1.42 KB
/
index.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
/* eslint no-console: 0 */
'use strict';
const emoji = require('node-emoji');
const chalk = require('chalk');
const store = require('./build/store');
const tasks = require('./build/tasks');
module.exports = (opts, flags) => {
if (!opts) {
console.log(
`${chalk.red.bold(
'Please pass in a command to execute.'
)} For more information, pass in ${chalk.yellow(
'--help'
)} to show help information.`
);
return;
}
switch (opts) {
case 'upload':
case 'up':
tasks.upload.run({
token: store.get('token'),
gistId: store.get('gistId'),
});
break;
case 'download':
case 'down':
case 'dl':
tasks.download.run({
token: store.get('token'),
gistId: store.get('gistId'),
});
break;
case 'init':
case 'i':
if (flags.token && !flags.id) {
tasks.init
.run({
token: flags.token,
})
.then((ctx) =>
console.log(`
Your Gist ID is ${chalk.yellow(ctx.gistId)}.
${chalk.red.bold('Please')} note it down.
You will need this when configuring machines
${emoji.get('computer')} to sync with.
`)
)
.catch((err) => console.log(err));
} else {
tasks.initSlave.run({
token: flags.token,
gistId: flags.id,
});
}
break;
default:
break;
}
};