Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cli-commands

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-commands

A convention for building command-driven CLI apps

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

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

Commands ⏏

Kind: Exported class


© 2016-18 Lloyd Brookes <75pound@gmail.com>. Documented by jsdoc-to-markdown.

Keywords

FAQs

Package last updated on 11 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc