# command-line-tool

> command-line-tool

Latest version **0.8.0** (published 2018-01-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install command-line-tool
pnpm add command-line-tool
yarn add command-line-tool
bun add command-line-tool
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2018-01-18 |
| First published | 2016-01-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.0.0 |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Lloyd Brookes |
| Maintainers | 75lb |

## Links

- npm: https://www.npmjs.com/package/command-line-tool
- Repository: https://github.com/75lb/command-line-tool
- Homepage: https://github.com/75lb/command-line-tool#readme
- Issues: https://github.com/75lb/command-line-tool/issues
- npm.io page: https://npm.io/package/command-line-tool

## Dependencies (5)

- [typical](https://npm.io/package/typical.md) ^2.6.1
- [array-back](https://npm.io/package/array-back.md) ^2.0.0
- [command-line-args](https://npm.io/package/command-line-args.md) ^5.0.0
- [command-line-usage](https://npm.io/package/command-line-usage.md) ^4.1.0
- [ansi-escape-sequences](https://npm.io/package/ansi-escape-sequences.md) ^4.0.0

## Recent versions

- 0.8.0 (latest) — 2018-01-18
- 0.7.0 — 2017-02-08
- 0.6.4 — 2016-10-06
- 0.6.3 — 2016-08-07
- 0.6.2 — 2016-08-02
- 0.6.1 — 2016-08-02
- 0.6.0 — 2016-07-30
- 0.5.2 — 2016-07-27
- 0.5.1 — 2016-07-27
- 0.5.0 — 2016-07-23
- 0.4.0 — 2016-07-12
- 0.3.1 — 2016-06-20
- 0.3.0 — 2016-06-18
- 0.2.1 — 2016-03-16
- 0.2.0 — 2016-03-09
- … 1 more at https://npm.io/package/command-line-tool/versions

## README

[![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)

<a name="module_command-line-tool"></a>

## 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) ⇒ <code>object</code>

<a name="module_command-line-tool.stop"></a>

### tool.stop([message])
Print the supplied messages then stop the process (no exit code).

**Kind**: static method of <code>[command-line-tool](#module_command-line-tool)</code>  

| Param | Type | Description |
| --- | --- | --- |
| [message] | <code>string</code> &#124; <code>Array.&lt;string&gt;</code> | One or more messages to be written to stderr before exiting. May contain `ansi.format` markup. |

<a name="module_command-line-tool.printError"></a>

### tool.printError(message)
Prints one or more strings in red to stderr.

**Kind**: static method of <code>[command-line-tool](#module_command-line-tool)</code>  

| Param | Type | Description |
| --- | --- | --- |
| message | <code>string</code> &#124; <code>Array.&lt;string&gt;</code> | input message(s) |

<a name="module_command-line-tool.printOutput"></a>

### tool.printOutput(message)
Prints one or more strings to stdout. Catches unwanted EPIPE error.

**Kind**: static method of <code>[command-line-tool](#module_command-line-tool)</code>  

| Param | Type | Description |
| --- | --- | --- |
| message | <code>string</code> &#124; <code>Array.&lt;string&gt;</code> | input message(s) |

<a name="module_command-line-tool.halt"></a>

### tool.halt([err], [options])
Stop the process with an error message.

**Kind**: static method of <code>[command-line-tool](#module_command-line-tool)</code>  

| Param | Type | Description |
| --- | --- | --- |
| [err] | <code>Error</code> | the error instance |
| [options] | <code>object</code> |  |
| [options.exitCode] | <code>number</code> | defaults to 1 |
| [options.stack] | <code>boolean</code> | defaults to false |

<a name="module_command-line-tool.getCli"></a>

### tool.getCli(definitions, [usageSections], [argv]) ⇒ <code>object</code>
Parse the command-line options.

**Kind**: static method of <code>[command-line-tool](#module_command-line-tool)</code>  

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


* * *

&copy; 2015-18 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

---
_Source: https://npm.io/package/command-line-tool · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
