clitookit
The command line toolkit
Installation
npm install clitoolkit
Quick Start
File /bin/test
:
#!/usr/bin/env node var clitoolkit = ; //initial other command line toolsclitoolkit;
Plugin clitoolkit-plugin-a
(clitoolkit-plugin-a/main.js):
module{ PluginAPI;};
Plugin clitoolkit-plugin-b
(clitoolkit-plugin-b/main.js):
module{ PluginAPI;};
Execute the command /bin/test
:
#show the usage of command test test --help#show the usage of command a test a --help#execute the command a test a -d -c#show the usage of command b test b --help#execute the command b test b -oi
Init API Options
opt
:type-> Object
the configrationversion
:type-> String
the command versionpluginBase(optional)
:type-> String
the plugin root pathplugin
:type-> Array
the clitoolkit plugins. if can not find the plugin in pluginBase clitoolkit will find node_modules which have the same name with the target plugin.
proArgv
:type-> Array
the progress's arguments(process.argv)
Plugin
- create a plugin for extend the command
- plugin is a folder contains a
main.js
main.js
should exports a function that with a PluginAPI arguments- you can use PluginAPI to register a new command
Example:
module{ PluginAPI;};
PluginAPI
register(name, desc, option, action)
name
:type-> String
command namedesc
:type-> String
descriptionoption
:type-> Array
command optionssample
:type-> String
command sample, e.g.: '-d, --dest 'desc(optional)
:type-> String
option descriptiondefVal(optional)
:type-> any
the default value
action
:type-> function
eval this function when the command trigger