Skip to content
A command line analyser for Node.JS
Find file
New pull request
Fetching latest commit...
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Node module - CMD-Conf

A command line analyser for Node.JS. View NPM registry

This module analyses the command line syntax to extract parameters and return them into an associative array.


I want to configure my listen port and activate the verbose mode like this :

$ node server.js -p 80 -v
$ node server.js --port 80 --verbose


    var cmdConf = require('cmd-conf');
        listenPort:{            // Define the 'listenPort' key configuration
            key: 'port',        // Configure command key name (different than param key)
            shortKey: 'p',      // Configure the short key
            action: 'get',      // Define action to get parameters in commande line.
            number: 1           // Define the number of parameters to get. (They must be consecutive)
            defaultValue: 85    // If the parameter not given, use the default value;

            shortKey: 'v',
            action: 'set',      // Set a static value
            value: true         // The value to set

        // If de action is not define, the item is consider as a static configuration.
            value: true

        staticString: 'foo bar'

    var params = cmdConf.getParameters();

    var myPort = params.listenPort;
    var verbose = params.verbose;

If you give a simple string to the configure() method, witch represent the path of a JSON file, cmd-conf try to resolve path and load config from this file.

More information coming soon

Something went wrong with that request. Please try again.