# commist

> Build your commands on minimist!

Latest version **3.2.0** (published 2022-12-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install commist
pnpm add commist
yarn add commist
bun add commist
```

## 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 | 3.2.0 |
| Published | 2022-12-13 |
| First published | 2014-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 20.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 99 |
| Author | Matteo Collina |
| Maintainers | matteo.collina |

## Links

- npm: https://www.npmjs.com/package/commist
- Repository: https://github.com/mcollina/commist
- Issues: https://github.com/mcollina/commist/issues
- npm.io page: https://npm.io/package/commist

## Recent versions

- 3.2.0 (latest) — 2022-12-13
- 3.1.2 — 2022-09-06
- 3.1.1 — 2022-09-06
- 3.1.0 — 2022-09-06
- 3.0.0 — 2022-07-19
- 2.0.0 — 2021-05-30
- 1.1.0 — 2019-02-28
- 1.0.0 — 2014-12-04
- 0.2.0 — 2014-08-13
- 0.1.0 — 2014-08-12

## README

commist
=======

Build command line application with multiple commands the easy way.
To be used with [minimist](http://npm.im/minimist).

```js
'use strict'

const program = require('commist')()
const result = program
  .register('abcd', function(args) {
    console.log('just do', args)
  })
  .register({ command: 'restore', equals: true }, function(args) {
    console.log('restore', args)
  })
  .register('args', function(args) {
    args = minimist(args)
    console.log('just do', args)
  })
  .register('abcde code', function(args) {
    console.log('doing something', args)
  })
  .register('another command', function(args) {
    console.log('anothering', args)
  })
  .parse(process.argv.splice(2))

if (result) {
  console.log('no command called, args', result)
}
```

To handle `async` operations, use `parseAsync` instead,
which let you await on registered commands execution.

```js
'use strict'

const program = require('commist')()

const result = await program
  .register('abcd', async function(args) {
    await executeCommand(args)
    await doOtherStuff()
  })
  .parseAsync(process.argv.splice(2))

if (result) {
  console.log('no command called, args', result)
}
```

When calling _commist_ programs, you can abbreviate down to three char
words. In the above example, these are valid commands:

```
node example.js abc
node example.js abc cod
node example.js anot comm
```

Moreover, little spelling mistakes are corrected too:

```
node example.js abcs cod
```

If you want that the command must be strict equals, you can register the
command with the json configuration:

```js
  program.register({ command: 'restore', strict: true }, function(args) {
    console.log('restore', args)
  })
```

If you want to limit the maximum levenshtein distance of your commands,
you can use `maxDistance: 2`:

```js
const program = require('commist')()
const minimist = require('minimist')

const result = program
  .register('abcd', function(args) {
    console.log('just do', args)
  })
  .register({ command: 'restore', equals: true }, function(args) {
    console.log('restore', args)
  })
  .register('args', function(args) {
    args = minimist(args)
    console.log('just do', args)
  })
  .register('abcde code', function(args) {
    console.log('doing something', args)
  })
  .register('another command', function(args) {
    console.log('anothering', args)
  })
  .parse(process.argv.splice(2))

if (result) {
  console.log('no command called, args', result)
}
```

License
-------

MIT

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