documentation in progress
Add a git-like command interface to your app. Wraps command-line-args.
Example
const commandLineCommands = require('command-line-commands')
// define your commands
const cli = commandLineCommands([
{ name: 'help' },
{ name: 'run', definitions: [ { name: 'why', type: String } ] }
])
// parse the command line
const command = cli.parse()
// respond
switch (command.name) {
case 'help':
console.log("I can't help you.")
break
case 'run':
console.log(`${command.options.why}: this is not a good reason.`)
break
default:
console.log(command.error + ':' + command.command);
}
Output (assumes your app name is example
):
$ example help
I can't help you.
$ example run --why terror
terror: this is not a good reason.
$ example hide
Unknown command: hide
Param | Type |
---|---|
commands | array |
Kind: instance method of CommandLineCommands
Param | Type |
---|---|
[argv] | array |
© 2015 Lloyd Brookes <[email protected]>. Documented by jsdoc-to-markdown.