c2h6o
v4.0.5
Published
CLI tools for node developing or console debugging
Downloads
6
Readme
CLI tools for node developing or console debugging
In current version there are several components inside this package:
clipp
: A cli param parser
Clip
is a class, you can use it to define arguments, and then get theirs value by parsing a string which formatted like shell command syntax.
Usage:
import { co, Clip } from 'c2h6o';
import { format } from './extractor';
const clip = new Clip([
{
'names': ['config', 'c'],
'description': 'Specify custom config file',
'optional': true,
},
{
'names': ['file', 'f'],
'description': 'Input file',
'optional': false,
},
{
'names': ['pattern', 'p'],
'optional': true,
},
{
'names': ['output', 'o'],
'description': 'Output file',
'optional': true,
// 'default': ''
}
]).parse(process.argv);
// Check if required entry provided and comform with `validator`'s rule
// this action can be omitted
clip.audit();
console.log(clip.getValue('config'));
co
: Tools to colorize output texts
co
is an object like console
.
the common log
method takes values with colorize gramma
to paint the output string.
It now ONLY suppts 256color shell or web-developer-tools console evironments.
Colorizing gramma:
co.log('Color #[f00]red#[] or #[00f]blue#[] string.');
co
is also a function which returns the formatted string instead of outputing
const costr = co('#[f00]A red string');