node-server-cli

1.0.2 • Public • Published

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".

Readme

Keywords

Package Sidebar

Install

npm i node-server-cli

Weekly Downloads

0

Version

1.0.2

License

MIT

Last publish

Collaborators

  • nicovank