kawkah
v1.0.27
Published
CLI argument parser with middleware support.
Downloads
7
Maintainers
Readme
An extensible command line parsing utility with middleware. Although fairly stable this module is not in production use as of 8/2018.
Key benefits of Kawkah are that it allows you to extend the validation pipeline and parsing via middleware. This allows you to easily create hooks for tracking usage or to add some sort of custom validation step.
Another key feature is the ability to build help groups for display. Kawkah is very customizable on this front. You can mix and match just about anything from examples to options to commands under a single heading with ease.
This is done by using namespaces. you might do something like:
kk.group('MyGroup', 'commandName.option', 'examples.name', 'Some static string of text');
We'll provide more on this soon...
Install
$ npm install kawkah
Usage
Here are the basics. After instantiating define your args, flags and other settings then call .listen() to have Kawkah listen for process.argv arguments.
import { Kawkah } from 'kawkah';
// OR
const Kawkah = require('kawkah').Kawkah;
const kk = new Kawkah({ /* options */ });
kk
.arg('order', {
coerce: v => v.toUpperCase()
})
.flag('toppings', {
type: 'array',
validate: /(cheese|mushroom|ham)/
})
.flag('deep-dish')
.listen('order --toppings cheese --toppings ham --deep-dish');
// RESULT
const result = {
{
_: [ 'ORDER' ],
__: [],
toppings: [ 'cheese', 'ham' ],
deepDish: true,
'$0': 'app',
'$command': null
}
}
Table of Contents
The documentation listed in this table of contents is here for convenience. If you find an error we suggest heading over to the Generated Docs. These tend to be pretty accurate given the cannot be generated without the project building. We try to keep examples up to date but there's only so much time. Feel free to create a PR if you see a mistake!
Docs
Documentation generated from source.
See https://blujedis.github.io/kawkah/
Change
See CHANGES.md
License
See LICENSE.md