add supportPassArgs for yargs, yargs the modern, pirate-themed, successor to optimist.
npm install yargs2add supportPassArgs for yargs, yargs the modern, pirate-themed, successor to optimist.
```
npm i yargs2
1. add yargs.processArgs, see Pull Requests# 1129
2. add options.supportPassArgs for use -- like npm run (enable by default)
> same usage and api with yargs
`ts
//import yargs = require('..');
import * as yargs from '..'
import { argv } from '..'
console.log(processArgs);
console.dir(yargs.processArgs);
console.log(argv);
console.dir(yargs.argv);
console.log('-------------------');
console.log(\supportPassArgs\ is enable by default\nif u don't want it\njust do \yargs(yargs.processArgs)\);
let y = yargs(yargs.processArgs);
console.log(processArgs);
console.dir(y.processArgs);
console.log(argv);
console.dir(y.argv);
console.log('-------------------');
console.log(enable \supportPassArgs\ again);
let y2 = yargs(yargs.processArgs, undefined, {
supportPassArgs: true,
});
console.log(processArgs);
console.dir(y2.processArgs);
console.log(argv);
console.dir(y2.argv);
`
`nodemon`
node demo.js -a 77777 666 -- --p 1 a b c
`ts`
processArgs
[ '-a', '77777', '666', '--', '--p', '1', 'a', 'b', 'c' ]
argv
{ _: [ 666 ],
a: 77777,
'$0': 'demo.js',
help: undefined,
version: undefined,
__: [ '--p', '1', 'a', 'b', 'c' ] }
supportPassArgs is enable by defaultyargs(yargs.processArgs)
if u don't want it
just do
`ts`
processArgs
[ '-a', '77777', '666', '--', '--p', '1', 'a', 'b', 'c' ]
argv
{ _: [ 666, '--p', '1', 'a', 'b', 'c' ],
a: 77777,
'$0': 'demo.js',
help: undefined,
version: undefined,
__: [] }
`ts``
processArgs
[ '-a', '77777', '666', '--', '--p', '1', 'a', 'b', 'c' ]
argv
{ _: [ 666 ],
a: 77777,
'$0': 'demo.js',
help: undefined,
version: undefined,
__: [ '--p', '1', 'a', 'b', 'c' ] }