JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 27424
  • Score
    100M100P100Q143349F
  • License MIT

Add a git-like command interface to your app

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

view on npm npm module downloads per month Build Status Dependency Status js-standard-style

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 ⏏

Kind: Exported class

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.