Simplifies creating CLI programs by combining minimist, show-help, show-version modules.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.gitignore
.npmignore
README.md
example
index.js
package.json

README.md

new-command

Simplifies creating command-line programs by combining minimist, show-help, show-version modules.

Usage Examples: prova, bud, personal-api, ourtunes

Install

$ npm install new-command

Usage

Defining Parameters

Define a command and options by calling new-command:

var command = require('new-command')({ 'p': 'port', 'n': 'hostname' })

command.port
// => 8080

command.hostname
// => foobar.com

command._
// => ['rest', 'of the', 'arguments']

Subcommands

To define subcommands like git push npm publish etc, just pass subcommand names before options:

command = require('new-command')('install', 'publish', 'unpublish', { r: 'registry', s: 'save' })



command.install
// => undefined

command.publish
// => true

command._subcommand
// => 'publish'

--version and --help

new-command will take care of --version (-v) and --help (-h) options for you, by calling show-version and show-help. So, if you call this command with -v parameter:

$ start-server --version

start-server v0.0.0

It reads your package name and version and outputs automatically. When user calls -h parameter:

$ start-server --help

It'll look for following paths in the project directory and will output the one it finds first:

  • docs/man
  • bin/help.txt
  • bin/usage.txt
  • help.txt
  • usage.txt
  • README
  • README.md
  • README.markdown