-
Notifications
You must be signed in to change notification settings - Fork 168
/
cli.js
executable file
·44 lines (39 loc) · 1.33 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
#!/usr/bin/env node
'use strict'
const path = require('node:path')
const commist = require('commist')()
const argv = require('yargs-parser')(process.argv)
const help = require('help-me')({
// the default
dir: path.join(path.dirname(require.main.filename), 'help')
})
const start = require('./start')
const eject = require('./eject')
const generate = require('./generate')
const generatePlugin = require('./generate-plugin')
const generateSwagger = require('./generate-swagger')
const generateReadme = require('./generate-readme')
const printRoutes = require('./print-routes')
const printPlugins = require('./print-plugins')
commist.register('start', start.cli)
commist.register('eject', eject.cli)
commist.register('generate', generate.cli)
commist.register('generate-plugin', generatePlugin.cli)
commist.register('generate-swagger', generateSwagger.cli)
commist.register('readme', generateReadme.cli)
commist.register('help', help.toStdout)
commist.register('version', function () {
console.log(require('./package.json').version)
})
commist.register('print-routes', printRoutes.cli)
commist.register('print-plugins', printPlugins.cli)
if (argv.help) {
const command = argv._.splice(2)[0]
help.toStdout(command)
} else {
const res = commist.parse(process.argv.splice(2))
if (res) {
// no command was recognized
help.toStdout(res)
}
}