Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on Apr 24, 2024 via pnpm

argparse 2.0.1

CLI arguments parser. Native port of python's argparse.
Package summary
Share
0
issues
1
license
1
Python-2.0
Package created
16 May 2012
Version published
28 Aug 2020
Maintainers
1
Total deps
1
Direct deps
0
License
Python-2.0

Issues

0
This package has no issues

Licenses

Python License 2.0

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
use-trademark
hold-liable
Must
include-copyright
include-license
state-changes
1 Packages, Including:
argparse@2.0.1
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of argparse 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does argparse do?

Argparse is a Command Line Interface (CLI) argument parser for Node.js, and is a native port of Python's argparse module. This package is designed to facilitate the parsing of command line arguments in your Node.js applications. Argparse supports sub-commands, similar to its original Python counterpart, and conveniently offers similar functionality in a JavaScript environment.

How do you use argparse?

Utilizing argparse in your Node.js application requires importing the ArgumentParser object from the 'argparse' module and using its methods to define the arguments your application expects. Here's a basic usage example:

#!/usr/bin/env node
'use strict';

const { ArgumentParser } = require('argparse');
const { version } = require('./package.json');

const parser = new ArgumentParser({
  description: 'Argparse example'
});

parser.add_argument('-v', '--version', { action: 'version', version });
parser.add_argument('-f', '--foo', { help: 'foo bar' });
parser.add_argument('-b', '--bar', { help: 'bar foo' });
parser.add_argument('--baz', { help: 'baz bar' });

console.dir(parser.parse_args());

In this example, the script accepts several optional arguments. Users can invoke the script with these flags followed by their respective values from the command line as follows:

$ ./test.js -f=3 --bar=4 --baz 5
{ foo: '3', bar: '4', baz: '5' }

The parser.parse_args() method parses the arguments and returns an object mapping argument names to their given values.

Where are the argparse docs?

The Argparse documentation can be found referenced in the original Python's argparse documentation and the original Python argparse tutorial. Additionally, you can also find more details including the difference with Python's argparse in the 'doc' directory of the argparse GitHub repository.