
clix
A tiny utility to make easy to create command line tools that require a config file in an easy way.
It uses optionator to parse the arguments
Overview
This module aims to make it easy the development of cli commands. It include the following options by default:
-
-h, --help
, useful help message (thanks to optionator).
-
-v, --version
, output the version of the module
-
-q, --quiet
, if the app prints logs using the provided log methods in the returned instance,
this will suppress the verbose output showing only a summary of the cli execution
-
-c, --config
, path to the configuration file (as json) to be used by this module
-
--colored-output
, wheter to use or not use color in the output messages. false
by default. **If you do want to enable
colors without passing this option you can set the environment variable __CLIX_COLORED_OUTPUT__
to true doing:
export __CLIX_COLORED_OUTPUT__=true
Install
npm i --save-dev clix
Usage
#!/usr/bin/env node
var programOptions = {
pkgJSONPath: path.resolve( __dirname, '../package.json' ),
configFile: {
defaultName: '.esformatter',
pathToLocalConfig: path.resolve( __dirname, '../configs/esformatter.json' ),
description: 'Path to your `esformatter` config, if not provided will try to use the `.esformatter` file in your current working directory, if not found will use the one provided with this package'
},
optionator: {
prepend: 'Usage: esbeautifier [options] glob [glob1] [glob2]..[globN]',
options: [
{
heading: 'Options'
},
{
option: 'checkOnly',
alias: 'k',
type: 'Boolean',
description: 'Will just run the beautifier and report which files need to be beautified'
},
{
option: 'useCache',
alias: 'u',
type: 'Boolean',
description: 'If true, this module will remember the `mtime` and `size` of the beatufied files and only operate on the ones that changed. If false, the cache will be destroyed. Cache will only be kept between executions with the useCache flag set to true.'
}
]
}
};
var clix = require( 'clix' );
clix.launch( programOptions, function ( program ) {
} );
Changelog
Changelog