# minus-h

> Add help generation to APIs created with Node's util.parseArgs function

Latest version **5.0.0** (published 2026-10-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install minus-h
pnpm add minus-h
yarn add minus-h
bun add minus-h
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2026-10-25 |
| First published | 2023-06-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 1 |
| Unpacked size | 14.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 3 |
| Author | Joe Hildebrand |
| Maintainers | hildjj |
| Keywords | parseArgs, node, util, help, -h, format, word-wrap |

## Links

- npm: https://www.npmjs.com/package/minus-h
- Repository: https://github.com/hildjj/minus-h
- Homepage: https://github.com/hildjj/minus-h#readme
- Issues: https://github.com/hildjj/minus-h/issues
- npm.io page: https://npm.io/package/minus-h

## Dependencies (1)

- [@cto.af/linewrap](https://npm.io/package/@cto.af/linewrap.md) 5.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 5.0.0 (latest) — 2026-10-25
- 4.0.1 — 2026-03-03
- 4.0.0 — 2025-09-10
- 3.0.2 — 2025-08-06
- 3.0.1 — 2025-06-09
- 3.0.0 — 2025-05-31
- 2.1.0 — 2024-08-08
- 2.0.1 — 2024-06-26
- 2.0.0 — 2024-03-08
- 1.2.1 — 2023-11-02
- 1.2.0 — 2023-10-31
- 1.1.3 — 2023-07-14
- 1.1.2 — 2023-07-14
- 1.1.1 — 2023-06-08
- 1.1.0 — 2023-06-08
- … 2 more at https://npm.io/package/minus-h/versions

## README

# minus-h

Add help generation to APIs created with Node's
[util.parseArgs()](https://nodejs.org/api/util.html#utilparseargsconfig)
function.

## Installation

```sh
npm install minus-h
```

### API

`parseArgsWithHelp()` is a function that wraps `util.parseArgs()`, adding
a "-h,--help" argument.  It takes one or two arguments.  The first argument is
an augmented version of the options passed to `util.parseArgs()`, with
descriptions provided for options as well as the command as a whole.  The second
optional argument is [options](https://github.com/cto-af/linewrap#options) for
line wrapping.  The wrapping width defaults to your terminal width (via
[process.stdout.columns](https://nodejs.org/api/tty.html#writestreamcolumns)).

```js
import {parseArgsWithHelp} from 'minus-h'

parseArgsWithHelp({
  description: 'A command that does something very interesting',
  argumentName: 'files',
  argumentDescription: 'the files to be processed',
  allowPositionals: true,
  options: {
    encoding: {
      type: 'string',
      argumentName: 'encoding',
      description: 'encoding for files read or written',
      choices: ["utf8", "base64"]
    },
  },
}, { width: 80 })
```

`node example.js --help` outputs the following to stderr, before exiting with
exit code 64:

```
Usage: example [options] [files]

A command that does something very interesting

Arguments:
  files                  the files to be processed

Options:
  --encoding <encoding>  encoding for files read or written (choices: "utf8",
                         "base64") Default: "utf8"
  -h,--help              display help for command
```

The `usage()` function takes the same two parameters.  It always writes
help information to output, then exits.  It is useful if you've detected a
higher level error condition with your input parameters, and want to re-iterate
the usage information to users as if they had used `--help`.

## Testing

Two more parameters may be added to the configuration parameter:

- `outputStream`: a writable stream to write the help text to.  Defaults to
  `process.stderr`.  Only the `write` method is ever called.
- `exit()`: a function that takes a number that is called when output is
   complete.  Defaults to `process.exit`.

These options are useful during testing so that you can catch the help text
that would have been written, and prevent your test harness from actually
exiting.

---
[![Tests](https://github.com/hildjj/minus-h/actions/workflows/node.js.yml/badge.svg)](https://github.com/hildjj/minus-h/actions/workflows/node.js.yml)
[![codecov](https://codecov.io/gh/hildjj/minus-h/graph/badge.svg?token=QQNMTT4XJQ)](https://codecov.io/gh/hildjj/minus-h)

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