minimist-expand
v0.4.1
Published
Expand minimist args with expand-object.
Downloads
20
Maintainers
Readme
minimist-expand
Expand minimist args with expand-object.
Install
Install with npm:
$ npm install minimist-expand --save
Without minimist-expand
$ --set=a:b,c,d
# results in => { _: [], set: 'a:b,d,d' }
With minimist-expand
$ --set=a:b
# results in => { _: [], set: {a: ['b', 'c', 'd']}}
Usage
Install minimist-plugins:
$ npm i minimist-plugins --save
Then add minimist-expand as a plugin:
var minimist = require('minimist');
var plugins = require('minimist-plugins');
var cli = plugins(mimimist)
.use(require('minimist-expand'));
// '$ --set=a:b'
cli.parse(process.argv.slice(2), function (err, res) {
//=> {_: [], set: {a: 'b'}}
});
Events
When used with minimist-events, call this plugin first so that events are emitted for all keys in the resulting object:
var minimist = require('minimist');
var plugins = require('minimist-plugins');
var cli = plugins(mimimist)
.use(require('minimist-expand'))
.use(require('minimist-events')());
cli.on('set', function (val) {
console.log('set =>', val);
//=> {a: 'b'}
});
// '$ --set=a:b'
cli.parse(process.argv.slice(2), function (err, res) {
//=> {_: [], set: {a: 'b'}}
});
Related projects
- expand-args: Expand parsed command line arguments using expand-object. | homepage
- expand-object: Expand a string into a JavaScript object using a simple notation. Use the CLI or… more | homepage
- minimist: parse argument options | homepage
- minimist-events: Add events to minimist, ~30 sloc. | homepage
- minimist-plugins: Simple wrapper to make minimist pluggable. ~20 sloc. | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Building docs
Generate readme and API documentation with verb:
$ npm install verb && npm run docs
Or, if verb is installed globally:
$ verb
Running tests
Install dev dependencies:
$ npm install -d && npm test
Author
Jon Schlinkert
License
Copyright © 2016 Jon Schlinkert Released under the MIT license.
This file was generated by verb, v0.9.0, on February 25, 2016.