-
-
Notifications
You must be signed in to change notification settings - Fork 157
/
Copy pathcli.js
126 lines (121 loc) · 3.26 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
const chalk = require('chalk')
const updateNotifier = require('update-notifier')
const pkg = require('../package.json')
const run = require('../lib')
updateNotifier({pkg: pkg}).notify()
const Locales = require('../tools/locales')
const y18n = new Locales()
require('yargonaut')
.style('yellow', 'required')
.helpStyle('green')
.errorsStyle('red.bold')
require('yargs')
.demandCommand(1, chalk.red('[ERROR] 0 arguments passed. Please specify a command'))
.strict()
.recommendCommands()
.usage(chalk.bold(y18n.__('usage') + ': docsify <init|serve> <path>'))
.command({
command: 'init [path]',
alias: 'i',
desc: chalk.gray(y18n.__('init')),
builder: yargs =>
yargs.options({
local: {
alias: 'l',
default: false,
desc: chalk.gray(y18n.__('init.local')),
nargs: 0,
requiresArg: false,
type: 'boolean'
},
theme: {
alias: 't',
default: 'vue',
desc: chalk.gray(y18n.__('init.theme')),
choices: ['vue', 'buble', 'dark', 'pure'],
nargs: 1,
requiresArg: true,
type: 'string'
}
}),
handler: argv => run.init(argv.path, argv.local, argv.theme)
})
.command({
command: 'serve [path]',
alias: 's',
desc: chalk.gray(y18n.__('serve')),
builder: yargs =>
yargs.options({
open: {
alias: 'o',
default: false,
desc: chalk.gray(y18n.__('serve.open')),
nargs: 0,
requiresArg: false,
type: 'boolean'
},
port: {
alias: 'p',
default: 3000,
desc: chalk.gray(y18n.__('serve.port')),
nargs: 1,
requiresArg: true,
type: 'number'
},
'livereload-port': {
alias: 'P',
default: 35729,
desc: chalk.gray(y18n.__('livereload.port')),
nargs: 1,
requiresArg: true,
type: 'number'
},
'index-name': {
alias: 'i',
desc: chalk.gray(y18n.__('serve.indexname')),
nargs: 1,
requiresArg: true,
type: 'string'
}
}),
handler: argv => run.serve(argv.path, argv.open, argv.port, argv.P, argv.i)
})
.command({
command: 'start <path>',
desc: chalk.gray(y18n.__('start')),
builder: yargs =>
yargs.options({
config: {
alias: 'c',
default: false,
desc: chalk.gray(y18n.__('start.config')),
nargs: 0,
requiresArg: false,
type: 'string'
},
port: {
alias: 'p',
default: 4000,
desc: chalk.gray(y18n.__('start.port')),
nargs: 1,
requiresArg: true,
type: 'number'
}
}),
handler: argv => run.start(argv.path, argv.config, argv.port)
})
.help()
.option('help', {
alias: 'h',
type: 'boolean',
desc: chalk.gray(y18n.__('help')),
group: chalk.green(y18n.__('group.globaloptions'))
})
.version('\ndocsify-cli version:\n ' + pkg.version + '\n')
.option('version', {
alias: 'v',
type: 'boolean',
desc: chalk.gray(y18n.__('version')),
group: chalk.green(y18n.__('group.globaloptions'))
})
.epilog(chalk.gray(y18n.__('epilog'))).argv