Gathering detailed insights and metrics for argparse
Gathering detailed insights and metrics for argparse
Gathering detailed insights and metrics for argparse
Gathering detailed insights and metrics for argparse
@types/argparse
TypeScript definitions for argparse
cli-argparse
Lightweight argument parser
@rushstack/ts-command-line
An object-oriented command-line parser for TypeScript
@ryancavanaugh/argparse
Type definitions for argparse v1.0.3 from https://www.github.com/DefinitelyTyped/DefinitelyTyped
CLI arguments parser for node.js. JS port of python's argparse module.
npm install argparse
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
491 Stars
267 Commits
73 Forks
21 Watching
2 Branches
21 Contributors
Updated on 31 Oct 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-7.3%
16,530,992
Compared to previous day
Last week
-0.3%
94,156,382
Compared to previous week
Last month
6.3%
404,603,712
Compared to previous month
Last year
27.2%
4,259,029,048
Compared to previous year
CLI arguments parser for node.js, with sub-commands support. Port of python's argparse (version 3.9.0).
Difference with original.
new ArgumentParser({ description: 'example', add_help: true })
.int
, float
, ...
.add_argument('-b', { type: 'int', help: 'help' })
.%r
format specifier uses require('util').inspect()
.More details in doc.
Following code is a JS program that takes a list of integers and produces either the sum or the max:
1const { ArgumentParser } = require('argparse')
2
3const parser = new ArgumentParser({ description: 'Process some integers.' })
4
5let sum = ints => ints.reduce((a, b) => a + b)
6let max = ints => ints.reduce((a, b) => a > b ? a : b)
7
8parser.add_argument('integers', { metavar: 'N', type: 'int', nargs: '+',
9 help: 'an integer for the accumulator' })
10parser.add_argument('--sum', { dest: 'accumulate', action: 'store_const',
11 const: sum, default: max,
12 help: 'sum the integers (default: find the max)' });
13
14let args = parser.parse_args()
15console.log(args.accumulate(args.integers))
Assuming the JS code above is saved into a file called prog.js, it can be run at the command line and provides useful help messages:
$ node prog.js -h
usage: prog.js [-h] [--sum] N [N ...]
Process some integers.
positional arguments:
N an integer for the accumulator
optional arguments:
-h, --help show this help message and exit
--sum sum the integers (default: find the max)
When run with the appropriate arguments, it prints either the sum or the max of the command-line integers:
$ node prog.js 1 2 3 4
4
$ node prog.js 1 2 3 4 --sum
10
If invalid arguments are passed in, it will issue an error:
$ node prog.js a b c
usage: prog.js [-h] [--sum] N [N ...]
prog.js: error: argument N: invalid 'int' value: 'a'
This is an example ported from Python. You can find detailed explanation here.
Since this is a port with minimal divergence, there's no separate documentation. Use original one instead, with notes about difference.
Available as part of the Tidelift Subscription
The maintainers of argparse and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
security policy file detected
Details
Reason
license file detected
Details
Reason
Found 6/24 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
detected GitHub workflow tokens with excessive permissions
Details
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
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