-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
64 lines (57 loc) · 1.4 KB
/
app.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
// const vorpal = require("vorpal")();
// vorpal.show()
const vorpal = require('vorpal')();
vorpal
.command('say [words...]')
.option('-b, --backwards')
.option('-t, --twice')
.action(function (args, callback) {
let str = args.words.join(' ');
str = (args.options.backwards) ?
str.split('').reverse().join('') :
str;
this.log(str);
callback();
})
vorpal
.command('sayapp [words...]')
.action(function (args, cb) {
this.log(args.words.join(' '));
cb();
});
vorpal
.command('reverse [words...]')
.action(function (args, cb) {
this.log(args.stdin.split('').reverse().join(''));
cb();
});
vorpal
.command('color [color] [text...]',"设置颜色")
.autocomplete(['2018-12-31', '2019-01-03', '2019-03-01'])
.action(function (args, cb) {
this.log(args)
this.log(vorpal.chalk[args.color](args.text.join('')));
cb();
});
vorpal
.command('order pizza')
.option('--anchovies')
.action(function (args, cb) {
const self = this;
this.prompt({
type: 'input',
name: 'time',
message: 'When would you like your pizza?'
}, function (result) {
self.log(`Okay, ${result.time} it is!`);
cb();
});
});
vorpal
.catch('[words...]', '帮助提示')
.action(function (args, cb) {
this.log(args.words.join(' ') + ' 请输入正确的命令');
cb();
});
vorpal.delimiter('dalongrong$').
show()