0.0.29 • Published 8 months ago

node-programmer v0.0.29

Weekly downloads
6
License
MIT
Repository
github
Last release
8 months ago

node-programmer

I hope it can become A coder/developer's assistant.

Using Params Library

This library provides an options parsing function.

Setting all availiable options

Command Line

node . --long-option-with-value a-value --long-option-without-value-is-enabling -s "short" input1 input2 input3...

Example Usage

// import the Params class
var Params = require('node-programmer/params');

var params = new Params({
    "long": "long",
    "port": "8080", 
    "host": "localhost",
    "static": "./static",
    "views": {default: "./views", short: "i"},
    "forward": false
});

/**
 * All the necessary arguments are included in the "opts" object
 */
var opts = params.getOpts();

/**
  * Opitons (Parameters / Arguments) count equals to the number of specified arguments, 
  * not the total count of all parameters you pass them to program from the command line
  * And the empty parameters will be ignored, and not included in the option count
  */
var optCount = params.getOptCount();

// do something if you don't get the right number of arguments
if (optCount < 1) {
    console.error("Not enough parameters provide");
    // print out the usage before exiting the program
    process.exit();
}    


// getting all the inputs, which is an array type even only one input is provided
var inputs = opts['---'];

Also you can see this project for example usage.

Maintainer

Eric Tang @ TYO Lab

0.0.29

8 months ago

0.0.27

10 months ago

0.0.28

10 months ago

0.0.25

2 years ago

0.0.26

2 years ago

0.0.24

3 years ago

0.0.22

3 years ago

0.0.23

3 years ago

0.0.21

3 years ago

0.0.20

4 years ago

0.0.19

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago