UNPKG

855 BJavaScriptView Raw
1#!/usr/bin/env node
2const cac = require('cac').default
3
4const cli = cac()
5
6cli
7 .command(
8 '*',
9 {
10 desc: 'Run a generator',
11 alias: 'run'
12 },
13 (input, flags) => {
14 const options = Object.assign(
15 {
16 generator: input[0],
17 outDir: input[1] || '.',
18 updateCheck: true
19 },
20 flags
21 )
22
23 if (!options.generator) {
24 return cli.showHelp()
25 }
26
27 return require('../')(options).run()
28 }
29 )
30 .option('npm-client', {
31 desc: `Use a specific npm client ('yarn' or 'npm')`,
32 type: 'string'
33 })
34 .option('update', {
35 desc: 'Update cached generator',
36 type: 'boolean',
37 alias: 'u'
38 })
39 .option('yes', {
40 desc: 'Use the default options',
41 alias: 'y'
42 })
43
44cli.on('error', error => {
45 return require('..').handleError(error)
46})
47
48cli.parse()