0.1.4 • Published 8 years ago

node-clii v0.1.4

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

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.

  1. Install the package named node-clii through npm.
  2. Create your cli application class and extend it with node-clii by requiring the package.

    const CLI = require('node-clii');
    class MyAwesomeCLI extends CLI {
    }
  3. Setup command actions.

    class MyAwesomeCLI extends CLI {
      helloCommand() {
        console.log('Hello CLI!');
      }
      
      fooBarCommand() {
        console.log('You have just run a sub command!');
      }
    }
  4. Create an instance of your class and run it.

    const myAwesomeApp = new MyAwesomeCLI();
    myAwesomeApp.run(process.argv);
  5. Try running theese commands.

    $ node filename.js hello
    Hello CLI!
    $ node filename.js foo bar
    You have just run a sub command!