simple command line api builder


simple command line api builder

CMDR is a simple library for command line APIs.

If you are not building a compiler and just need a small hammer, use CMDR.

Maybe you need to build a big bloated, every-parameters-are-inside-flags

$ full --feature -d --command-line "app"

If that's the case, ok, use one of the many existing command-line libs on NPM.

But maybe you just want to put a simple command system in a few minutes, eg like

$ simple cli app

If that's the case, give a try to CMDR.

Here is a quick demo. See the examples/ dir for more.

var cmdr = require("cmdr");
  "^say ([a-z]+) (\\d+) times?"function (msgtimes) {
    // no parseInt but some JS black magic, do not try this at home 
    for (var i = 0; i < times; i++) {

Now you can call you command line API this way:

$ node examples/demo.js say apple 1 time apple

$ node examples/demo.js say beetlejuice 3 times beetlejuice beetlejuice beetlejuice

BSD (see LICENCE.txt for details)