Package Exports
- cli-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 (cli-commands) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
cli-commands
A convention for building command-driven CLI apps.
Synopsis
const CliCommands = require('cli-commands')
const validCommands = [
{ name: null },
{ name: 'show', command: require('./command/show').create() },
{ name: 'serve', command: require('./command/serve').create() },
{ name: 'help', command: require('./command/help').create() }
]
const cliCommands = new CliCommands(validCommands)
Where each command looks something like this:
class ShowCommand {
optionDefinitions () {
/* command has a --help option */
return [
{ name: 'help', type: Boolean, alias: 'h' }
]
}
description () { return 'Print some information.' }
usage () {
return [
{ header: 'Options', optionList: this.optionDefinitions() }
]
}
cliView (data) {
return JSON.stringify(data, null, ' ')
}
execute (options) {
// do something sync or async
}
static create () {
return new this(...arguments)
}
}
API Reference
cli-commands
CliCommmands ⏏
new CliCommmands(commandDefinitions)
Param | Type | Description |
---|---|---|
commandDefinitions | Array.<object> |
One or more command definitions. |
© 2016-17 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.