Gathering detailed insights and metrics for command-line-args
Gathering detailed insights and metrics for command-line-args
Gathering detailed insights and metrics for command-line-args
Gathering detailed insights and metrics for command-line-args
A mature, feature-complete library to parse command-line options.
npm install command-line-args
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
697 Stars
431 Commits
106 Forks
6 Watching
3 Branches
11 Contributors
Updated on 27 Nov 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-12.4%
427,278
Compared to previous day
Last week
0.7%
2,520,620
Compared to previous week
Last month
13.5%
10,247,756
Compared to previous month
Last year
20.3%
97,946,364
Compared to previous year
4
1
1
Upgraders, please read the release notes
A mature, feature-complete library to parse command-line options.
You can set options using the main notation standards (learn more). These commands are all equivalent, setting the same values:
$ example --verbose --timeout=1000 --src one.js --src two.js
$ example --verbose --timeout 1000 --src one.js two.js
$ example -vt 1000 --src one.js two.js
$ example -vt 1000 one.js two.js
To access the values, first create a list of option definitions describing the options your application accepts. The type
property is a setter function (the value supplied is passed through this), giving you full control over the value received.
1const optionDefinitions = [ 2 { name: 'verbose', alias: 'v', type: Boolean }, 3 { name: 'src', type: String, multiple: true, defaultOption: true }, 4 { name: 'timeout', alias: 't', type: Number } 5]
Next, parse the options using commandLineArgs():
1import commandLineArgs from 'command-line-args' 2const options = commandLineArgs(optionDefinitions)
options
now looks like this:
1{ 2 src: [ 3 'one.js', 4 'two.js' 5 ], 6 verbose: true, 7 timeout: 1000 8}
Beside the above typical usage, you can configure command-line-args to accept more advanced syntax forms.
Command-based syntax (git style) in the form:
$ executable <command> [options]
For example.
$ git commit --squash -m "This is my commit message"
Command and sub-command syntax (docker style) in the form:
$ executable <command> [options] <sub-command> [options]
For example.
$ docker run --detached --image centos bash -c yum install -y httpd
A usage guide (typically printed when --help
is set) can be generated using command-line-usage. See the examples below and read the documentation for instructions how to create them.
A typical usage guide example.
The polymer-cli usage guide is a good real-life example.
There is plenty more to learn, please see the wiki for examples and documentation.
1$ npm install command-line-args --save
© 2014-24 Lloyd Brookes <opensource@75lb.com>.
Documented by jsdoc-to-markdown.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
6 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 5
Reason
Found 4/24 approved changesets -- score normalized to 1
Reason
dependency not pinned by hash detected -- score normalized to 0
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-25
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