Create figgy-pudding instances from yargs options
One day, long ago, it was Talk Like A Pirate Day and Butterscotch Pudding Day.
$ npm install butterscotch-pudding
const bp = require('butterscotch-pudding');
const yargs = require('yargs/yargs');
const opts = {
ships: {
type: 'number',
default: 3,
},
distance: {
type: 'number',
},
color: {
type: 'string',
defaultDescription: 'butterscotch',
},
};
const CommandOptions = bp(opts);
const argv = yargs().options(opts).parse('--distance 100 --color chartreuse --cutlass');
const opts = CommandOptions(argv);
opts.get('ships'); // => 3
opts.get('color'); // => 'chartreuse'
opts.get('cutlass'); // => Error: CommandOptions does not define 'cutlass'