Set process.env[DEBUG]
given process.argv
npm i @maboiteaspam/set-verbosity --save
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
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
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
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(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(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
.
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);