Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on Apr 26, 2024 via pnpm

arg 5.0.2

Unopinionated, no-frills CLI argument parser
Package summary
Share
0
issues
1
license
1
MIT
Package created
1 Jun 2012
Version published
5 Jun 2022
Maintainers
5
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
arg@5.0.2
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 arg 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does arg do?

"arg" is a lightweight, unopinionated, and straightforward command-line argument parser for Node.js applications. It does not enforce any particular way of handling command-line options, instead offering a flexible and efficient method for reading command-line arguments passed to the application.

How do you use arg?

To use the "arg" package in your project, first, you need to install it using npm:

npm install arg

Then, require the package in your script, and call the "arg" function, passing it an object that defines the command-line options and flags that your script expects:

const arg = require('arg');

const args = arg({
	'--help': Boolean, // a Boolean option (--help)
	'--version': Boolean, // a Boolean option (--version)
	'--verbose': arg.COUNT, // a count option (--verbose), counts the number of times it is passed
	'--port': Number, // a number option (--port), expects a number as argument
	'--name': String, // a string option (--name), expects a string as argument
	'--tag': [String], // an array option (--tag), can be passed multiple times with different strings
	'-v': '--verbose', // aliases -v to --verbose
	'-n': '--name', // aliases -n to --name
	'--label': '--name', // aliases --label to --name
});

This will parse the command-line arguments passed to your script and return an object where the keys are the options and flags and the values are their arguments or counts. All extra parameters not consumed by options are added to result._.

For comprehensive customization, you can use second optional argument that provides parsing options to modify the behavior of arg(), like argv, permissive, and stopAtPositional.

Where are the arg docs?

The documentation for "arg" is primarily contained in the README.md file found at the package's GitHub repository, which is git+https://github.com/vercel/arg.git. The README provides detailed descriptions of how to use the package, including how to define specifications for command-line options and flags, how to create aliases, handle unknown or multiple arguments, and set parsing options. It also includes comprehensive examples of its usage. The source code itself is also well-commented, providing further insight into its functionality.