concon

0.2.0 • Public • Published

Concon

Version 0.2.0

Concon is a command line tool for Node.js that helps you take control your configurations.

Installation:

Install Concon globally:

sudo npm install -g concon

Initialize your module and add a configuration variable:

sudo npm init
sudo concon add port 80 hello world

Install Concon locally

sudo npm install concon

Use the Concon module in your app:

var http = require('http');
var concon = require('concon');

concon(function(error, config){
    
    if(error) throw err;
    
    var server = http.createServer(function(request, response){
        response.writeHead(200);
        response.write(config.hello);
        response.end();
    });
    
    server.listen(config.port, function(error){
        if(!error) console.log('\nListening on port: ' + config.port);
    });
});

Documentation (Command Line):

Warning: Concon will only work if you've already made a package.json.

Warning: By default if no other command is recognized, Concon assumes that you are trying to update key/value pairs. It's likely your main intent, and this makes things faster.

add:

Adds one or more key/value pairs to the config in your package.json.

sudo concon port 80
sudo concon add port 80
sudo concon add port 80 hello world

update:

Updates one or more key/value pairs.

sudo concon port 3000
sudo concon update port 3000
sudo concon update port 80 hello world

rm/remove:

Removes one or more keys.

sudo concon rm port
sudo concon rm port hello
sudo concon remove port

ls/list:

Lists the current configuration in the package.json.

concon ls
concon list

Documentation (The Module):

Options:

- Required Keys (Optional):

An Array of keys that are critical to the callback's operation. If one of these keys is missing, Concon pass back an error into the callback.

- Callback:

This function gets two arguments back (error, config). If there is an error, you should probably just throw it. But, it's your choice.

Example:

var http = require('http');
var concon = require('concon');

//get the config object, required keys are 'port' and 'hello'.
concon(['port', 'hello'], function(error, config){
    
    if(error) throw err;
    
    //create server that passes back the value of key 'hello'.
    var server = http.createServer(function(request, response){
        response.writeHead(200);
        response.write(config.hello);
        response.end();
    });
    
    //have the server listen on the value of key 'port'
    server.listen(config.port, function(error){
        if(!error) console.log('\nListening on port: ' + config.port);
    });
});

License

MIT

Author:

Tyler Waite

Readme

Keywords

Package Sidebar

Install

npm i concon

Weekly Downloads

0

Version

0.2.0

License

MIT

Last publish

Collaborators

  • headbash