@minimist-functions
This is a small wrapper for minimist that will automatically call functions based on the args passed.
Install
With yarn
yarn add minimist-functions
Or NPM
npm install minimist-functions
Uninstall
With yarn
yarn remove minimist-functions
Or NPM
npm uninstall minimist-functions
Usage
Use minimist as normal but instead of require('minimist')
you must use require('minimist-functions')
.
const args = processargv alias: h: 'help' s: 'showMyValue' t: 'test' default: dir: process
Then define / attach your functions:
const help = { console // Stop exuction of subsequent args } const showMyValue = { console} const test = { console} args
With the above setup, the following would be output:
C:\> yourcli -h// Some help C:\> yourcli -s SomeVal -t HelloWorld// You entered SomeVal// Test called with arg: HelloWorld// Will be called providing
minimist-functions API
Run just like minimist (substituting minimist
for minimist-functions
)
const args = args opts
See: minimist methods for parameter information.
args.process(functionMaps)
This will read your function maps and automatically call them based on the parameters passed through.
functionMaps
(Object): Functions which map to your verbose arguments.
See usage for examples.
Roadmap
- Automatic -h, --help functions based on JSDoc data against functions.
License
MIT ©2019 - present - Allan Gaunt