Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bezoerb/group-args
CLI helper to group commandline arguments
https://github.com/bezoerb/group-args
Last synced: 14 days ago
JSON representation
CLI helper to group commandline arguments
- Host: GitHub
- URL: https://github.com/bezoerb/group-args
- Owner: bezoerb
- License: mit
- Created: 2016-04-19T22:22:25.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-04-20T14:40:42.000Z (over 8 years ago)
- Last Synced: 2024-10-18T19:17:09.244Z (26 days ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- License: license
Awesome Lists containing this project
README
# group-args [![Build Status](https://travis-ci.org/bezoerb/group-args.svg?branch=master)](https://travis-ci.org/bezoerb/group-args) [![Coverage Status](https://coveralls.io/repos/github/bezoerb/group-args/badge.svg?branch=master)](https://coveralls.io/github/bezoerb/group-args?branch=master)
> CLI helper to group commandline arguments
## Install
```
$ npm install --save group-args
```## Usage
```bash
node ./cli.js --foo --bar something --group-a 1 --group-b 2
```
```js
const groupArgs = require('group-args');// process.argv: [
groupArgs('group');
//=> {foo: true, bar: 'something', group: { a: 1, b: 2 }}
```## API
### groupArgs(key, [options], [minimistOptions])
#### key
Type: `string|array|object`
Group arguments by key. When passing an object it is
Could be `'key'`, `['key1','key2']`, `{alias1: 'key1', alias2: 'key2'}`#### options
##### argv
Type: `array|object`
Default: `process.argv.slice(2)`Arguments array or already parsed arguments.
##### delimiter
Type: `string`
Default: `-`Delimiter between group identifier & key.
##### strict
Type: `bool`
Default: `true`Disable to allow camelCased arguments provided by e.g. [`meow`](https://github.com/sindresorhus/meow)
##### alias
Type: `string`
Default: `undefined`Alias for identifier (short opt)
##### camelCase
Type: `bool`
Default: `true`camelCase grouped arguments
#### minimistOptions
See [`minimist`](https://github.com/substack/minimist#var-argv--parseargsargs-opts)
## License
MIT © [Ben Zörb](http://sommerlaune.com)