0.8.0 • Published 6 years ago

command-line-tool v0.8.0

Weekly downloads
75,761
License
MIT
Repository
github
Last release
6 years ago

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

ParamTypeDescription
messagestring | 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

ParamTypeDescription
messagestring | 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

ParamTypeDescription
messagestring | Array.<string>input message(s)

tool.halt(err, options)

Stop the process with an error message.

Kind: static method of command-line-tool

ParamTypeDescription
errErrorthe error instance
optionsobject
options.exitCodenumberdefaults to 1
options.stackbooleandefaults to false

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

Parse the command-line options.

Kind: static method of command-line-tool

ParamTypeDescription
definitionsArray.<OptionDefinitions>to be passed to command-line-args
usageSectionsArray.<section>to be passed to command-line-usage
argvArray.<string>If supplied, this argv array is parsed instead of process.argv.

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