GitXplorerGitXplorer
m

set-verbosity

public
3 stars
0 forks
1 issues

Commits

List of commits on branch master.
Unverified
25748464b9b17af823de014dfcd55b6fad4d7ca1

better README

mmaboiteaspam committed 9 years ago
Unverified
23f4805a061bdcd667de386c0b79516ecf0faa88

better README

mmaboiteaspam committed 9 years ago
Unverified
669c6bcfc95fa10d7a12e89be9823cd9f3a05799

better README

mmaboiteaspam committed 9 years ago
Unverified
ddc819a5c74d8969766b2b2df54f0cee7ce35980

patch 2.0.3

mmaboiteaspam committed 9 years ago
Unverified
66d14b9f56340459cb5c1415916c0466d39dc958

add tests and fix some cases of parsing

mmaboiteaspam committed 9 years ago
Unverified
5ab1b3114f3ed7415b3d02a7acce41ee5350625c

patch 2.0.2

mmaboiteaspam committed 9 years ago

README

The README file for this repository.

set-verbosity

Set process.env[DEBUG] given process.argv

Install

npm i @maboiteaspam/set-verbosity --save

Usage

process.argv

Using the node process.argv value

var pkg = require('./package.json');
var debug = require('@maboiteaspam/set-verbosity')(pkg.name, process.argv);
// or var debug = require('@maboiteaspam/set-verbosity');
//    .raw(pkg.name, process.argv.join(' '));

debug('hello');

Which then, can be invoked in such fashion

module-name -v
module-name --verbose
module-name -v module-name
module-name --verbose module-name,tomate,set-verbosity

minimist

Using minimist module to pre parse values

var pkg = require('./package.json');
var argv  = require('minimist')(process.argv.slice(2));
var debug = require('@maboiteaspam/set-verbosity')(pkg.name, argv.v || argv.verbose);
// or var debug = require('@maboiteaspam/set-verbosity');
//  .parsed(pkg.name, argv.v || argv.verbose);

debug('hello');

Which then, can be invoked in such fashion

module-name -v
module-name --verbose
module-name -v module-name
module-name --verbose module-name,tomate,set-verbosity

debug object

This module returns instances of debug module

var pkg = require('./package.json');
var debug = require('@maboiteaspam/set-verbosity')(pkg.name, process.argv);

debug('hello');

Which then, can be invoked in such fashion

module-name -v
module-name --verbose
module-name -v module-name
module-name --verbose module-name,tomate,set-verbosity

Api

setVerbosity

setVerbosity is a function object with two additional methods raw, parsed.

  • setVerbosity(string name, object arg) debug

When typeof(arg) is object, returns setVerbosity.raw(name, arg)

  • setVerbosity(string name, string arg) debug

When typeof(arg) is string, returns setVerbosity.parsed(name, arg)

  • setVerbosity(string name, bool arg) debug

When typeof(arg) is bool, returns setVerbosity.parsed(name, arg)

setVerbosity.parsed

  • setVerbosity.parsed(string name, string verboseModules)

Set process.env['DEBUG'] to verboseModules.

  • setVerbosity.parsed(string name, bool verbose) debug

Set process.env['DEBUG'] to name.

setVerbosity.raw

  • setVerbosity.raw(string name, string argv) debug

Parse argv to extract -v || --verbose (verboseModules)?. Set process.env['DEBUG'] to verboseModules or name.

  • setVerbosity.raw(string name, bool verbose) debug

Set process.env['DEBUG'] to name.

Examples

var pkg = require('./package.json');
var debug = require('@maboiteaspam/set-verbosity')(pkg.name, process.argv);
var debug = require('@maboiteaspam/set-verbosity').raw(pkg.name, process.argv);

var argv  = require('minimist')(process.argv.slice(2));
var debug = require('@maboiteaspam/set-verbosity')(pkg.name, argv.v || argv.verbose);
var debug = require('@maboiteaspam/set-verbosity').parsed(pkg.name, argv.v || argv.verbose);

More