1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | 'use strict';
|
9 |
|
10 | const cli = require('yargs');
|
11 | const packageJson = require('../package.json');
|
12 |
|
13 | async function main({ argv }) {
|
14 | cli
|
15 | .scriptName(packageJson.name)
|
16 | .version(packageJson.version)
|
17 | .usage('Usage: $0 [options]');
|
18 |
|
19 | cli
|
20 | .commandDir('commands')
|
21 | .strict()
|
22 | .fail((message, error, yargs) => {
|
23 | if (error) {
|
24 | if (error.stderr) {
|
25 | console.error(error.stderr);
|
26 | process.exit(1);
|
27 | }
|
28 | throw error;
|
29 | }
|
30 | console.log(message);
|
31 | console.log(yargs.help());
|
32 | process.exit(1);
|
33 | })
|
34 | .parse(argv.slice(2)).argv;
|
35 | }
|
36 |
|
37 | module.exports = main;
|