command-line-tool
command-line-tool
Last updated 8 years ago by 75lb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install command-line-tool 
SYNC missed versions from official npm registry.

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

command-line-tool

Some conventional operations used in command-line tools.

Example

const tool = require('command-line-tool')

tool.stop([message])

Print the supplied messages then stop the process (no exit code).

Kind: static method of command-line-tool

Param Type Description
[message] string | Array.<string> One or more messages to be written to stderr before exiting. May contain ansi.format markup.

tool.printError(message)

Prints one or more strings in red to stderr.

Kind: static method of command-line-tool

Param Type Description
message string | Array.<string> input message(s)

tool.printOutput(message)

Prints one or more strings to stdout. Catches unwanted EPIPE error.

Kind: static method of command-line-tool

Param Type Description
message string | Array.<string> input message(s)

tool.halt([err], [options])

Stop the process with an error message.

Kind: static method of command-line-tool

Param Type Description
[err] Error the error instance
[options] object
[options.exitCode] number defaults to 1
[options.stack] boolean defaults to false

tool.getCli(definitions, [usageSections], [argv]) ⇒ object

Parse the command-line options.

Kind: static method of command-line-tool

Param Type Description
definitions Array.<OptionDefinitions> to be passed to command-line-args
[usageSections] Array.<section> to be passed to command-line-usage
[argv] Array.<string> If supplied, this argv array is parsed instead of process.argv.

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

Current Tags

  • 0.8.0                                ...           latest (8 years ago)

16 Versions

  • 0.8.0                                ...           8 years ago
  • 0.7.0                                ...           9 years ago
  • 0.6.4                                ...           10 years ago
  • 0.6.3                                ...           10 years ago
  • 0.6.2                                ...           10 years ago
  • 0.6.1                                ...           10 years ago
  • 0.6.0                                ...           10 years ago
  • 0.5.2                                ...           10 years ago
  • 0.5.1                                ...           10 years ago
  • 0.5.0                                ...           10 years ago
  • 0.4.0                                ...           10 years ago
  • 0.3.1                                ...           10 years ago
  • 0.3.0                                ...           10 years ago
  • 0.2.1                                ...           10 years ago
  • 0.2.0                                ...           10 years ago
  • 0.1.0                                ...           10 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (5)
Dev Dependencies (2)

Copyright 2013 - present © cnpmjs.org | Home |