Installations
npm install minimist-options
Developer
vadimdemedes
Developer Guide
Module System
Unable to determine the module system for this package.
Min. Node Version
>= 6
Typescript Support
No
Node Version
12.13.1
NPM Version
6.12.1
Statistics
54 Stars
46 Commits
17 Forks
3 Watching
1 Branches
9 Contributors
Updated on 09 Feb 2023
Languages
JavaScript (84.19%)
TypeScript (15.81%)
Total Downloads
Cumulative downloads
Total Downloads
2,145,853,880
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
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
3
Dev Dependencies
4
minimist-options
Write options for minimist and yargs in a comfortable way. Supports string, boolean, number and array options.
Installation
$ npm install --save minimist-options
Usage
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);
Array 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.
License
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
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
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
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/vadimdemedes/minimist-options/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/vadimdemedes/minimist-options/test.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/test.yml:18
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 9 are checked with a SAST tool
Score
3.6
/10
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