cmd

Composable command line application library

  • cmd

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
cmd
0.1.07 years ago12 years agoMinified + gzip package size for cmd in KB

Readme

cmd
Composable command line application library
NOTE: This library is unstable and very much in a pre-alpha state.

Install

npm install cmd --save

Usage

var cli = require('cmd')
var command = require('cmd-command')
var flag = require('cmd-flag')
var alias = require('cmd-alias')
var handler = require('cmd-handler')

var login = command(
  alias('login', 'l'),
  handler(function (context) {

    // Do some login logic

    // context.data
    // context.flags
    // context.options
  })
)

var tokenFlag = flag(
  alias('-t', '--token'),
  handler(function (token, context) {

    // Do some token logic

    // token is input from argv
    // context.data
    // context.flags
    // context.options
  })
)

var run = cli(
  login(/* pass in options here */),
  tokenFlag(/* pass in options here */)
)

run(process.argv.slice(2))