Package Exports
- command-line-commands
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (command-line-commands) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
documentation in progress
command-line-commands
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('Unknown 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.
CommandLineCommands ⏏
new CommandLineCommands(commands)
Param | Type |
---|---|
commands | array |
commandLineCommands.parse([argv]) ⇒ object
Kind: instance method of CommandLineCommands
Param | Type |
---|---|
[argv] | array |
© 2015 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.