# clut

> Tiny module with simple utility functions for parsing command line arguments

Latest version **1.0.0** (published 2022-02-20) · ISC license · 0 weekly downloads

## Install

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

## 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 | 2022-02-20 |
| First published | 2022-02-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mats Rörbecker |
| Maintainers | matsrorbecker |
| Keywords | cli, command-line, terminal |

## Links

- npm: https://www.npmjs.com/package/clut
- Repository: https://github.com/matsrorbecker/clut
- Homepage: https://github.com/matsrorbecker/clut#readme
- Issues: https://github.com/matsrorbecker/clut/issues
- npm.io page: https://npm.io/package/clut

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2022-02-20

## README

# clut
Tiny module with simple utility functions for parsing command line arguments.

## Usage
Simple example:

```javascript
#!/usr/bin/env node

const clut = require('clut')

// script for searching e.g. Wikipedia and optionally pretty-print result

const options = ['lang', 'pretty']
const {
  args,
  knownFlags,
  unknownFlags,
  hasUnknownFlags,
  getFlags,
  parseArg,
  parseBoolean
} = clut(process.argv, options)

if (!args.length) {
  console.log('No arguments provided...')
  console.log('Allowed options:')
  options.forEach(option => {
    console.log(`${option} (${getFlags(option)})`)
  })
  process.exit(0)
}

if (hasUnknownFlags) {
  console.log('Unknown option(s):', unknownFlags)
  process.exit(0)
}

const searchTerm = args[0]
const lang = parseArg('lang') || 'en'
const pretty = parseBoolean('pretty')

console.log(searchTerm, lang, pretty)

// rest of code goes here

```

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