npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dabrowskif/simplecli

v0.4.0

Published

Simple arg parsing tool for CLI libraries

Downloads

9

Readme

@dabrowskif/simplecli

Simple CLI argument parser with full TypeScript support. So - it is typesafe. Aaand.. it is simple. Aaand... it works. Shocking? I know.

Features

Type Safety That Doesn't Lie: CLI keys and JSON keys are fully typed and validated at compile time. No more mysterious runtime errors because you typo'd --prot instead of --port and spent 3 hours debugging why your server won't start.

Duplicate Prevention: Because apparently some people think passing --verbose --verbose --verbose makes things extra verbose. Spoiler alert: it doesn't.

Flexible Parsing: Supports both --key=value and --key value formats, because i am NOT monsters who force you into one arbitrary convention.

Installation

npm install @dabrowskif/simplecli

or

yarn add @dabrowskif/simplecli

Quick Start

import { CLI } from '@dabrowskif/simplecli';

const args = new CLI()
  .addArg({
    cliKeys: ['--name', '-n'],
    jsonKey: 'name',
    required: true
  })
  .addArg({
    cliKeys: ['--age'],
    jsonKey: 'age',
    type: 'number'
  })
  .build();

// node script.js --name John --age 25
console.log(args.name); // string (guaranteed to exist)
console.log(args.age);  // number | undefined (properly typed)

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | defaultType | 'string' \| 'number' \| 'boolean' | 'string' | Default type for arguments when not specified. Because guessing is for amateurs. | | defaultRequired | boolean | false | Makes all arguments required by default. Use with caution - your users will hate you. | | ignoreUnknownArgs | boolean | true | Silently ignore unknown arguments. Set to false if you enjoy angry error messages. | | preventDuplicateArgs | boolean | true | Prevents duplicate arguments. Turn off if you like chaos. | | explicitBooleanValues | boolean | false | Requires explicit true/false values for booleans instead of just presence. For the pedantic. |

API Reference

Constructor

new CLI()

Methods

.withOptions(options)

Configure the CLI parser behavior.

const cli = new CLI().withOptions({
  defaultType: 'string',
  defaultRequired: false,
  ignoreUnknownArgs: true,
  preventDuplicateArgs: true,
  explicitBooleanValues: false
});

.withArgv(argv: string[])

Set custom arguments to parse. Defaults to process.argv.slice(2) because that's what you want 99% of the time.

.addArg(argument)

Add an argument definition with full type safety.

interface Argument {
  cliKeys: string[];                              // CLI flags: ['--name', '-n']
  jsonKey: string;                                // Result object key
  required?: boolean;                             // Override default requirement
  type?: 'string' | 'number' | 'boolean';       // Override default type
}

.build()

Parse the arguments and return a fully typed result object. This is where the magic happens.

Examples

Web Server Configuration

const config = new CLI()
  .addArg({ cliKeys: ['--port', '-p'], jsonKey: 'port', type: 'number', required: true })
  .addArg({ cliKeys: ['--host'], jsonKey: 'host', required: true })
  .addArg({ cliKeys: ['--verbose'], jsonKey: 'verbose', type: 'boolean' })
  .build();

// node server.js --port 8080 --host localhost --verbose
// Result: { port: number, host: string, verbose?: boolean}

Required by Default

const config = new CLI()
  .withOptions({ defaultRequired: true })
  .addArg({ cliKeys: ['--database-url'], jsonKey: 'databaseUrl' })
  .addArg({ cliKeys: ['--dry-run'], jsonKey: 'dryRun', type: 'boolean', required: false })
  .build();

// node migrate.js --database-url "postgresql://..." --dry-run
// Result: { databaseUrl: string, dryRun?: boolean }

Strict Mode with Explicit Booleans

const config = new CLI()
  .withOptions({ 
    explicitBooleanValues: true,  // Requires --watch true/false
    ignoreUnknownArgs: true       // Throws on unknown args
  })
  .addArg({ cliKeys: ['--watch'], jsonKey: 'watch', type: 'boolean' })
  .addArg({ cliKeys: ['--workers'], jsonKey: 'workers', type: 'number' })
  .build();

// node build.js --watch true --workers 4
// Result: { watch?: boolean, workers?: number }

// node build.js --watch true --workers 4 --some-random-arg argvalue
// Result: throws an Error!