node-clii
v0.1.4
Published
CLI Framework for developing command-line based applications in NodeJS.
Readme
node-cli
CLI Framework for developing command-line based applications in NodeJS.
TODO (v0.2.0)
- [x] Command factories
- [x] Command descriptions
- [ ] Command arguments and options
- [ ] Event ordering and interupting
- [ ] Automaticily generated help command
Basic Usage
IMPORTANT NOTE You will need EcmaScript version 6 supported compiler to run this example directly. Otherwise take a look at Babel for working with es6.
- Install the package named
node-cliithrough npm. - Create your cli application class and extend it with
node-cliiby requiring the package.
const CLI = require('node-clii');
class MyAwesomeCLI extends CLI {
}- Setup command actions.
class MyAwesomeCLI extends CLI {
helloCommand() {
console.log('Hello CLI!');
}
fooBarCommand() {
console.log('You have just run a sub command!');
}
}- Create an instance of your class and run it.
const myAwesomeApp = new MyAwesomeCLI();
myAwesomeApp.run(process.argv);- Try running theese commands.
$ node filename.js hello
Hello CLI!
$ node filename.js foo bar
You have just run a sub command!