Socket
Socket
Sign inDemoInstall

@eegli/tinyparse

Package Overview
Dependencies
0
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @eegli/tinyparse

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


Version published
Weekly downloads
171
decreased by-5.52%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

0.19.1

Patch Changes

  • 94284db: Flag options can now be configured to be one of a set of available values!

Readme

Source

Tinyparse

npm GitHub Workflow Status (branch) codecov npm bundle size (scoped)

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

What it is

Like oclif and Yargs had a baby.

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

Resources

This project has been guided by the amazing Command Line Interface Guidelines by Aanand Prasad, Ben Firshman, Carl Tashian and Eva Parish.

Further inspiration has been taken from the Apache Commons CLI.

Keywords

FAQs

Last updated on 12 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc