-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.js
63 lines (50 loc) · 1.08 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
'use strict';
/* eslint-disable global-require */
const load = require('./config/load');
const [ command, ...args ] = process.argv.slice(2);
const config = load(
__dirname,
process.env,
'plugins.json');
if (command === 'start') {
const Composer = require('telegraf/composer');
const start = require('./bot/start');
const load = require('./plugins/load');
return start(
args[0] || process.env.TOKEN || config.options.token,
config.plugins.map(plugin =>
load(
process.cwd(),
plugin,
(config.pluginOptions || {})[plugin] || {},
Composer,
{})));
}
const write = require('./config/write');
if (command === 'add') {
const add = require('./command/add');
return write('plugins.json', add(config, args));
}
// TODO below
if (command === 'remove') {
return write(remove(
args,
config));
}
if (command === 'set') {
return write(set(
args.slice(0, -1),
...args.slice(-1),
config));
}
if (command === 'push') {
return write(push(
args.slice(0, -1),
...args.slice(-1),
config));
}
if (command === 'unset') {
return write(unset(
args,
config));
}