1.0.8 • Published 8 years ago

opt-stack v1.0.8

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

opt-stack

Build status Git tag NPM version Code style

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 field
  • schema - psuedo schema, if val its a default value, if type its a required field

Returns: options

License

MIT