|
1 | 1 | 'use strict' |
2 | 2 |
|
3 | | -const { execute } = require('./core') |
| 3 | +const {execute} = require('./core') |
4 | 4 |
|
5 | | -const { argv, showHelp } = require('yargs') |
6 | | -.wrap(null) // specify no column limit (no right-align) |
7 | | -.usage('Usage: $0 <command> [options]') |
8 | | -.help('h') |
9 | | -.alias('h', 'help') |
10 | | -.version() |
11 | | -.alias('v', 'version') |
| 5 | +const yargs = require('yargs/yargs')(process.argv.slice(2)); |
12 | 6 |
|
13 | | -.boolean('raw-input') |
14 | | -.alias('x', 'raw-input') |
15 | | -.describe('raw-input', 'Read input as a string') |
| 7 | +const {hideBin} = require('yargs/helpers'); |
| 8 | +const argv = yargs.usage('Usage: $0 <command> [options]') |
| 9 | + .help('h') |
| 10 | + .alias('h', 'help') |
| 11 | + .version() |
| 12 | + .alias('v', 'version') |
16 | 13 |
|
17 | | -.boolean('json') |
18 | | -.alias('j', 'json') |
19 | | -.describe('json', 'Force JSON output') |
| 14 | + .boolean('raw-input') |
| 15 | + .alias('x', 'raw-input') |
| 16 | + .describe('raw-input', 'Read input as a string') |
20 | 17 |
|
21 | | -.boolean('color') |
22 | | -.alias('C', 'color') |
23 | | -.describe('color', 'Colorize JSON (--color=false to disable it)') |
| 18 | + .boolean('json') |
| 19 | + .alias('j', 'json') |
| 20 | + .describe('json', 'Force JSON output') |
| 21 | + |
| 22 | + .boolean('color') |
| 23 | + .alias('C', 'color') |
| 24 | + .describe('color', 'Colorize JSON (--color=false to disable it)') |
| 25 | + |
| 26 | + .describe('require', 'require the given module') |
| 27 | + .alias('r', 'require') |
| 28 | + .argv; |
24 | 29 |
|
25 | | -.describe('require', 'require the given module') |
26 | | -.alias('r', 'require'); |
27 | 30 |
|
28 | 31 | if (process.stdin.isTTY) { |
29 | | - showHelp(); |
30 | | - process.exit(0); |
| 32 | + yargs.showHelp(); |
| 33 | + //showHelp(); |
| 34 | + //process.exit(0); |
| 35 | + |
| 36 | + return; |
31 | 37 | } |
32 | 38 |
|
33 | | -const options = Object.assign({}, argv, { transform: argv._[0] }) |
| 39 | +const options = Object.assign({}, argv, {transform: argv._[0]}) |
34 | 40 | execute(process.stdin, options, (err, result) => { |
35 | | - if (err) { |
36 | | - console.error(err.message); |
37 | | - process.exit(1); |
38 | | - } |
| 41 | + if (err) { |
| 42 | + console.error(err.message); |
| 43 | + process.exit(1); |
| 44 | + } |
39 | 45 |
|
40 | | - console.log(result); |
| 46 | + console.log(result); |
41 | 47 | }) |
0 commit comments