1.0.8 • Published 7 years ago

node-cli-args v1.0.8

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

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
1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago