node-cli-args
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

node-cli-args

A simple argument manager for node

Installation

npm i --save node-cli-args

Usage

var nodeArgs = require('node-cli-args');
var argManager = new nodeArgs.ArgumentManager();

// Argument(long, short, defaultValue)
argManager.on(new nodeArgs.Argument('url','u', 'localhost'), function(val, defaultValue) {
    // val will be default value if no value is provided
    console.log('Your url argument has a value of: ' + val);
});

argManager.onDefault(function(defaults) {
    defaults.forEach(function(arg) {
        console.log('Unprefixed argument: ' + arg);
    });
});

Command line:

mycli --url=localhost helloWorld goodbye

or (short args don't support assigning values)

mycli -u helloWorld goodbye

Output:

Your url argument has a value of: localhost
Unprefixed argument: helloWorld
Unprefixed argument: goodbye

Readme

Keywords

none

Package Sidebar

Install

npm i node-cli-args

Weekly Downloads

0

Version

1.0.8

License

MIT

Last publish

Collaborators

  • cpamperin