npm install node-server-cli --save
const cli = require("node-server-cli");
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']
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']
cli.removeCommand("test");
// Removes command test or set of commands with name "test".