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 8, 2024 via pnpm

nopt 3.0.6

Option parsing for Node, supporting types, shorthands, etc. Used by npm.
Package summary
Share
0
issues
1
license
2
ISC
Package created
30 Mar 2011
Version published
12 Nov 2015
Maintainers
5
Total deps
2
Direct deps
1
License
ISC

Issues

0
This package has no issues

Licenses

ISC License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
Cannot
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
abbrev@1.1.1
nopt@3.0.6
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

1
All Dependencies CSV
β“˜ This is a list of nopt 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
abbrev1.1.12.25 kBISC
prod

Visualizations

Frequently Asked Questions

What does nopt do?

Nopt is an option parsing utility for Node.js. By examining user input, Nopt conveniently informs an application about the types of the values provided, making it possible to manage them accordingly. It is an important tool for writing complex, configurable programs in the Node environment. Notably, this package is leveraged by npm for its functionality.

How do you use nopt?

To use Nopt, start by including it in your Node.js script using require("nopt").

Example:

var nopt = require("nopt")
  , Stream = require("stream").Stream
  , path = require("path")
  , knownOpts = { "foo" : [String, null]
                , "bar" : [Stream, Number]
                , "baz" : path
                , "bloo" : [ "big", "medium", "small" ]
                , "flag" : Boolean
                , "pick" : Boolean
                , "many1" : [String, Array]
                , "many2" : [path, Array]
                }
  , shortHands = { "foofoo" : ["--foo", "Mr. Foo"]
                 , "b7" : ["--bar", "7"]
                 , "m" : ["--bloo", "medium"]
                 , "p" : ["--pick"]
                 , "f" : ["--flag"]
                 }
var parsed = nopt(knownOpts, shortHands, process.argv, 2)
console.log(parsed)

In this script, you can define types and values for options with the knownOpts object. Then user-input arguments can be shortened using the shortHands object. When the script is run with different option arguments, Nopt parses them and the console.log(parsed) output reflects the parsed options.

Where are the nopt docs?

The documentation for Nopt is included in its source file, lib/nopt.js, at the bottom. The tests serve as examples showcasing of how to use the package and what it is capable of doing. You can also visit the package's GitHub repository at https://github.com/npm/nopt to find the readme and code examples.