Gathering detailed insights and metrics for minimist-options
Gathering detailed insights and metrics for minimist-options
Gathering detailed insights and metrics for minimist-options
Gathering detailed insights and metrics for minimist-options
npm install minimist-options
Module System
Unable to determine the module system for this package.
Min. Node Version
Typescript Support
Node Version
NPM Version
54 Stars
46 Commits
17 Forks
3 Watching
1 Branches
9 Contributors
Updated on 09 Feb 2023
JavaScript (84.19%)
TypeScript (15.81%)
Cumulative downloads
Total Downloads
Last day
-9.1%
2,156,550
Compared to previous day
Last week
1.6%
13,045,514
Compared to previous week
Last month
20.7%
52,176,759
Compared to previous month
Last year
0.9%
525,819,460
Compared to previous year
3
4
Write options for minimist and yargs in a comfortable way. Supports string, boolean, number and array options.
$ npm install --save minimist-options
1const buildOptions = require('minimist-options');
2const minimist = require('minimist');
3
4const options = buildOptions({
5 name: {
6 type: 'string',
7 alias: 'n',
8 default: 'john'
9 },
10
11 force: {
12 type: 'boolean',
13 alias: ['f', 'o'],
14 default: false
15 },
16
17 score: {
18 type: 'number',
19 alias: 's',
20 default: 0
21 },
22
23 arr: {
24 type: 'array',
25 alias: 'a',
26 default: []
27 },
28
29 strings: {
30 type: 'string-array',
31 alias: 's',
32 default: ['a', 'b']
33 },
34
35 booleans: {
36 type: 'boolean-array',
37 alias: 'b',
38 default: [true, false]
39 },
40
41 numbers: {
42 type: 'number-array',
43 alias: 'n',
44 default: [0, 1]
45 },
46
47 published: 'boolean',
48
49 // Special option for positional arguments (`_` in minimist)
50 arguments: 'string'
51});
52
53const args = minimist(process.argv.slice(2), options);
instead of:
1const minimist = require('minimist'); 2 3const options = { 4 string: ['name', '_'], 5 number: ['score'], 6 array: [ 7 'arr', 8 {key: 'strings', string: true}, 9 {key: 'booleans', boolean: true}, 10 {key: 'numbers', number: true} 11 ], 12 boolean: ['force', 'published'], 13 alias: { 14 n: 'name', 15 f: 'force', 16 s: 'score', 17 a: 'arr' 18 }, 19 default: { 20 name: 'john', 21 f: false, 22 score: 0, 23 arr: [] 24 } 25}; 26 27const args = minimist(process.argv.slice(2), options);
The array
types are only supported by yargs.
minimist does not explicitly support array type options. If you set an option multiple times, it will indeed yield an array of values. However, if you only set it once, it will simply give the value as is, without wrapping it in an array. Thus, effectively ignoring {type: 'array'}
.
{type: 'array'}
is shorthand for {type: 'string-array'}
. To have values coerced to boolean
or number
, use boolean-array
or number-array
, respectively.
MIT © Vadim Demedes
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 8/29 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More