UNPKG

803 BJavaScriptView Raw
1/**
2 * Copyright IBM Corp. 2019, 2019
3 *
4 * This source code is licensed under the Apache-2.0 license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8'use strict';
9
10const cli = require('yargs');
11const packageJson = require('../package.json');
12
13async 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
37module.exports = main;