yargs
Install
npm i yargs
npm i @types/yargs --save-dev
#!/usr/bin/env node
const yargs = require('yargs/yargs');
const { hideBin } = require('yargs/helpers');
const argv = yargs(hideBin(process.argv)).argv;
console.log(argv);
if (argv.ships > 3 && argv.distance < 53.5) {
console.log('Plunder more riffiwobbles!');
} else {
console.log('Retreat from the xupptumblers!');
}
➜ trader git:(master) ✗ npm run test ships -- --a=1 a
> trader@1.0.0 test
> node app.js "ships" "--a=1" "a"
{ _: [ 'ships', 'a' ], a: 1, '$0': 'app.js' }
Retreat from the xupptumblers!