@zacklukem/cmdjs
v0.0.2
Published
An library for creating command line interfaces
Downloads
3
Readme
cmd.js
A lightweight library for parsing arguments in a command line interface (CLI).
Usage
Import this library
const {CommandParser, Command, HelpCommand} = require('cmdjs');
Create a command parser
const parser = new CommandParser();
Add some commands
const myCommand = new Command(['hi', 'hello'], '<name> - Says Hello!', args => {
console.log("Hello, " + args[0] + "!");
});
parser.addCommand(myCommand);
Create a help command:
parser.addCommand(new HelpCommand('This is a hello test!', parser));
Then parse some arguments:
parser.parse(['help']);
parser.parse(['hi', "World"]);
This should return:
This is a hello test!
hi,hello <name> - Says Hello!
Hello, World!