# @eegli/tinyparse

> A tiny utility for parsing & validating Node CLI args and object literals

Latest version **0.20.0** (published 2024-10-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install @eegli/tinyparse
pnpm add @eegli/tinyparse
yarn add @eegli/tinyparse
bun add @eegli/tinyparse
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.20.0 |
| Published | 2024-10-19 |
| First published | 2022-01-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 0 |
| Unpacked size | 62.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| GitHub stars | 4 |
| Author | Eric Egli |
| Maintainers | eeric |
| Keywords | cli, node, parse, argv, validate, argument, utility, typescript |

## Links

- npm: https://www.npmjs.com/package/@eegli/tinyparse
- Repository: https://github.com/eegli/tinyparse
- Homepage: https://tinyparse.dev/
- Issues: https://github.com/eegli/tinyparse/issues
- npm.io page: https://npm.io/package/@eegli/tinyparse

## 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

- 0.20.0 (latest) — 2024-10-19
- 0.0.1-1 (alpha) — 2022-01-06
- 0.19.1 — 2024-03-12
- 0.19.0 — 2024-03-07
- 0.18.3 — 2024-03-01
- 0.18.2 — 2024-02-29
- 0.18.1 — 2024-02-27
- 0.18.0 — 2024-02-25
- 0.17.1 — 2024-02-25
- 0.17.0 — 2024-02-23
- 0.16.0 — 2024-02-22
- 0.15.1 — 2024-01-04
- 0.15.0 — 2024-01-04
- 0.14.0 — 2023-03-02
- 0.13.0 — 2023-02-23
- … 16 more at https://npm.io/package/@eegli/tinyparse/versions

## README

## Tinyparse

![npm](https://img.shields.io/npm/v/@eegli/tinyparse) ![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/eegli/tinyparse/ci.yml?branch=main) [![codecov](https://codecov.io/gh/eegli/tinyparse/branch/main/graph/badge.svg?token=8MFDR4SWYM)](https://codecov.io/gh/eegli/tinyparse) ![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@eegli/tinyparse)

> A tiny, type-safe and flexible utility for creating command line tools in Node.js

## What it is

_Like [oclif](https://oclif.io/) and [Yargs](https://yargs.js.org/) had a baby._

```ts
import { Parser } from '@eegli/tinyparse';

new Parser()
  .option('occasion', {
    longFlag: '--occasion',
    shortFlag: '-o',
    defaultValue: '',
    required: true,
  })
  .subcommand('congratulate', {
    args: ['name'] as const,
    handler: ({ args, options }) => {
      const [name] = args;
      const { occasion } = options;
      console.log(`Happy ${occasion}, ${name}!`);
    },
  })
  .defaultHandler(() => {
    console.log('Please enter your name');
  })
  .parse(['congratulate', 'John', '--occasion', 'birthday'])
  .call();

// Happy birthday, John!
```

I use this mostly for other pet projects of mine so it comes with some opinions 🤪.

## Features

- TypeScript first - 100% type-safety
- Supports subcommands and flag options
- Async API
- Lightweight - Zero dependencies
- Mega customizable

## Examples

- Check out the extensive [test suites](https://github.com/eegli/tinyparse/tree/main/test) or
- Play in the dedicated [Code Sandbox](https://codesandbox.io/s/tinyparse-sandbox-pknk4?file=/src/index.ts)

## Resources

This project has been guided by the amazing [Command Line Interface Guidelines](https://clig.dev/) by Aanand Prasad, Ben Firshman, Carl Tashian and Eva Parish.

Further inspiration has been taken from the [Apache Commons CLI](https://commons.apache.org/proper/commons-cli/).

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