https://github.com/eegli/tinyparse
A tiny, type-safe and flexible framework to build powerful CLI apps
https://github.com/eegli/tinyparse
argv cli command-line commander javascript minimist nodejs parser typescript validation yargs
Last synced: about 1 month ago
JSON representation
A tiny, type-safe and flexible framework to build powerful CLI apps
- Host: GitHub
- URL: https://github.com/eegli/tinyparse
- Owner: eegli
- License: mit
- Created: 2022-01-05T08:23:50.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-23T17:59:30.000Z (7 months ago)
- Last Synced: 2025-03-27T10:39:49.280Z (about 2 months ago)
- Topics: argv, cli, command-line, commander, javascript, minimist, nodejs, parser, typescript, validation, yargs
- Language: TypeScript
- Homepage: https://tinyparse.dev
- Size: 3.07 MB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: docs/README.md
- Changelog: CHANGELOG.md
- Contributing: docs/contributing.md
- License: LICENSE
Awesome Lists containing this project
README
## Tinyparse
  [](https://codecov.io/gh/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/).