1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# minimist-options [![Build Status](https://travis-ci.org/vadimdemedes/minimist-options.svg?branch=master)](https://travis-ci.org/vadimdemedes/minimist-options)
> Write options for [minimist](https://npmjs.org/package/minimist) in a comfortable way.
## Installation
```
$ npm install --save minimist-options
```
## Usage
```js
const buildOptions = require('minimist-options');
const minimist = require('minimist');
const options = buildOptions({
name: {
type: 'string',
alias: 'n',
default: 'john'
},
force: {
type: 'boolean',
alias: ['f', 'o'],
default: false
},
published: 'boolean',
// special option for positional arguments (`_` in minimist)
arguments: 'string'
});
const args = minimist(options);
```
instead of:
```js
const minimist = require('minimist');
const options = {
string: ['name', '_'],
boolean: ['force', 'published'],
alias: {
n: 'name',
f: 'force',
o: 'force'
},
default: {
name: 'john',
f: false
}
};
const args = minimist(options);
```
## License
MIT © [Vadim Demedes](https://vadimdemedes.com)
|