dashdash
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
assert-plus | 1.0.0 | 3.85 kB | MIT | prod |
Dashdash is a lightweight, featureful, and explicit option-parsing library for Node.js. It's designed to tackle shortcomings of other popular option parsing libraries, providing precise control over command line arguments interpretation. Dashdash supports types for options, auto-generated help, custom option types, and bash completion.
Dashdash can be used by first installing it via npm. The command for this is npm install dashdash
. Once installed, you can use it in your JavaScript files by requiring the module and defining the options for your CLI. Here's a short example of usage:
var dashdash = require('dashdash');
var options = [
{
names: ['help', 'h'],
type: 'bool',
help: 'Print this help and exit.'
}
];
var opts = dashdash.parse({options: options});
console.log("opts:", opts);
console.log("args:", opts._args);
Of course, you can have more complex options and command line interfaces using dashdash. In your application, opts
will contain parsed options and _args
will contain arguments after the options. This way, you can handle the logic of options and arguments in your application.
The documentation for dashdash can be found directly in its source code hosted on GitHub. It provides a detailed overview of all the features and use-cases supported by the library, from installation and basic usage to more advanced topics such as defining complex options and adding custom option types.