0.1.4 • Published 8 years ago
node-clii v0.1.4
node-cli
CLI Framework for developing command-line based applications in NodeJS.
TODO (v0.2.0)
- Command factories
- 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-clii
through npm. Create your cli application class and extend it with
node-clii
by 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!