opt-stack
v1.0.8
Published
Get options from a stack of sources.
Downloads
9
Readme
opt-stack
Get options from a stack of sources ... cli, package, defaults.
Features
- 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
Installation
$ npm install opt-stack
Usage
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')
API
optStack(name, schema)
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
License
MIT