Get options from a stack of sources ... cli, package, defaults.
- Pull options from
name
field in package.json - Pull options from cli
- Coerce strings into numbers and booleans
- Supports default values
- Specify required options
- Optionally create your own option stack with environment support
$ npm install opt-stack
var optStack = require('opt-stack')
// node cli --foo=cli
optStack('woot', {foo: 'bar'}) // => {foo: 'cli'}
optStack('woot', {qux: String}) // => throw new Error('qux required')
optStack('woot', {foo: 1}) // => throw new TypeError('got string for "foo", expecting number')
name
- name is use for env prefix and packageJson fieldschema
- psuedo schema, if val its a default value, if type its a required field
Returns: options
MIT