[![view on npm](http://img.shields.io/npm/v/command-line-tool.svg)](https://www.npmjs.org/package/command-line-tool)
[![npm module downloads](http://img.shields.io/npm/dt/command-line-tool.svg)](https://www.npmjs.org/package/command-line-tool)
[![Build Status](https://travis-ci.org/75lb/command-line-tool.svg?branch=master)](https://travis-ci.org/75lb/command-line-tool)
[![Dependency Status](https://david-dm.org/75lb/command-line-tool.svg)](https://david-dm.org/75lb/command-line-tool)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)
## command-line-tool
Some conventional operations used in command-line tools.
**Example**
```js
const tool = require('command-line-tool')
```
* [command-line-tool](#module_command-line-tool)
* [.stop([message])](#module_command-line-tool.stop)
* [.printError(message)](#module_command-line-tool.printError)
* [.printOutput(message)](#module_command-line-tool.printOutput)
* [.halt([err], [options])](#module_command-line-tool.halt)
* [.getCli(definitions, [usageSections], [argv])](#module_command-line-tool.getCli) ⇒ object
### tool.stop([message])
Print the supplied messages then stop the process (no exit code).
**Kind**: static method of [command-line-tool](#module_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](#module_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](#module_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](#module_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](#module_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](https://github.com/jsdoc2md/jsdoc-to-markdown).