1.0.2 • Published 7 years ago

node-server-cli v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

node-server-cli

Install

npm install node-server-cli --save
const cli = require("node-server-cli");

How to use

Register a new command

cli.setCommand("test", (params, flags) => {
    console.log(params, flags);
});

When test thisfile.js andthisone.html -v --save is typed:

  • params == ['thisfile.js', 'andthisone.html']
  • flags == ['save', 'v']

Register a new set of commands

cli.setCommand("test", {
    foo(params, flags) {
        console.log("foo", params, flags);
    },
    bar(params, flags) {
        console.log("bar", params, flags);
    }
});

When test foo bar --foo -bar is typed, the function foo in the passed object is called, and:

  • params == ['bar']
  • flags == ['foo', 'bar']

Remove a command or set of commands

cli.removeCommand("test");
// Removes command test or set of commands with name "test".