# mtd-help

> A helpful Track.

Latest version **1.0.0** (published 2016-05-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install mtd-help
pnpm add mtd-help
yarn add mtd-help
bun add mtd-help
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-05-27 |
| First published | 2016-01-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Colin 'Oka' Hall-Coates |
| Maintainers | oka |
| Keywords | mtd |

## Links

- npm: https://www.npmjs.com/package/mtd-help
- Repository: https://github.com/Okahyphen/mtd-help
- Homepage: https://github.com/Okahyphen/mtd-help#readme
- Issues: https://github.com/Okahyphen/mtd-help/issues
- npm.io page: https://npm.io/package/mtd-help

## Dependencies (1)

- [chalk](https://npm.io/package/chalk.md) ^1.1.1

## Recent versions

- 1.0.0 (latest) — 2016-05-27
- 0.1.1 — 2016-01-22
- 0.1.0 — 2016-01-19

## README

# `mtd-help`

[![NPM version][npm-image]][npm-url] [![Downloads][npm-downloads]][npm-url]

This module provides an easy way to define a `help` track for applications using [mtd][mtd].

## Install

Using [npm](https://www.npmjs.com/).

```shell
$ npm install mtd-help
```

## Example

A simple example.

```javascript
// simple.js
'use strict';

const Depot = require('mtd');
const help = require('mtd-help');

new Depot()

.default('help', [], help(
  { name: 'Help Example',
    hide: false },
  { foo: 'A line about foo.',
    bar: 'A line about bar.',
    help: 'Display this message.' }
))

.track(
  'foo',
  [
    { $: 'zal', alias: 'z', info: 'A description for zal.' },
    { $: 'qux', _: 'hello, world', alias: 'q', info: 'A description for qux.' }
  ],
  (zal, qux) => console.log(zal, qux)
)

.track(
  'bar',
  [ { $: 'baz', alias: 'b', info: 'A description for baz.' } ],
  baz => console.log(baz)
)

.embark();

```

Running our example application either as `$ node simple.js` or verbosely as `$ node simple.js help` will print the following to our terminal, complete with pretty colours.

```
Help Example

[ Multiple: On ][ Reruns: Off ][ Warnings: On ]

[ bar ] A line about bar.
  --baz, -b  
    A description for baz.

[ foo ] A line about foo.
  --zal, -z  
    A description for zal.
  --qux, -q  (default: hello, world)
    A description for qux.

[ help ] (default) Display this message.

```

## Documentation

Require the module, as you would any other Node module.

```javascript
const help = require('mtd-help');
```

`help` is now a factory function that creates a suitable `Track` _block_. It has the following signature.

```javascript
factory (
    settings: HelpSettings,
    descriptions: GenericObject = {}
): Block
```

`HelpSettings` is an interface that looks like:

```javascript
interface HelpSettings {
    /*
     * The name of your application,
     * displayed at the top of the help print out.
     */
    name: string;

    /*
     * Whether to list the track that is
     * associated with the block generated
     * in the final output.
     */
    hide: boolean;
}
```

`descriptions` is a `GenericObject`:

```javascript
interface GenericObject extends Object {
    [index: string]: any;
}
```

Its keys should be strings, corresponding to `Track` handles in your application. Each value should be a description of the matching track.

---

Enjoy!

[oka.io](http://oka.io/)

[npm-url]: https://www.npmjs.com/package/mtd-help
[npm-image]: http://img.shields.io/npm/v/mtd-help.svg
[npm-downloads]: http://img.shields.io/npm/dm/mtd-help.svg

[mtd]: https://github.com/Okahyphen/mtd

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