butterscotch-pudding
v2.0.0
Published
Create figgy-pudding instances from yargs options
Downloads
8
Maintainers
Readme
butterscotch-pudding
Create figgy-pudding instances from yargs options
One day, long ago, it was Talk Like A Pirate Day and Butterscotch Pudding Day.
Install
$ npm install butterscotch-pudding
Usage
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'