Expand minimist args with expand-object.
npm install minimist-expand> Expand minimist args with expand-object.
Install with npm:
``sh`
$ npm install minimist-expand --save
Without minimist-expand
`sh`
$ --set=a:b,c,dresults in => { _: [], set: 'a:b,d,d' }
With minimist-expand
`sh`
$ --set=a:bresults in => { _: [], set: {a: ['b', 'c', 'd']}}
Install minimist-plugins:
`sh`
$ npm i minimist-plugins --save
Then add minimist-expand as a plugin:
`js
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'}}
});
`
When used with minimist-events, call this plugin first so that events are emitted for all keys in the resulting object:
`js
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'}}
});
`
* 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
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Generate readme and API documentation with verb:
`sh`
$ npm install verb && npm run docs
Or, if verb is installed globally:
`sh`
$ verb
Install dev dependencies:
`sh``
$ npm install -d && npm test
Jon Schlinkert
* github/jonschlinkert
* twitter/jonschlinkert
Copyright © 2016 Jon Schlinkert
Released under the MIT license.
*
_This file was generated by verb, v0.9.0, on February 25, 2016._