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

@jiakun-zhao/cli

v0.0.1

Published

A lightweight CLI parsing library with full TypeScript type inference. Generated by AI.

Downloads

13

Readme

@jiakun-zhao/cli

NPM Version NPM Version

A lightweight CLI parsing library with full TypeScript type inference.

Features

  • Command names can contain spaces (e.g. deploy production)
  • Full type inference for action callbacks based on registered options
  • Automatic --help and --version generation
  • Zero runtime dependencies

Install

pnpm add @jiakun-zhao/cli

Usage

Basic

import { Program } from '@jiakun-zhao/cli'

const program = new Program({
  name: 'mycli',
  version: '1.0.0',
  description: 'A CLI tool',
})

program
  .command('deploy production', 'Deploy to production')
  .option('--host', 'Server host', String)
  .option('--port', 'Server port', Number)
  .option('--verbose', 'Verbose output', Boolean)
  .action((opts) => {
    // opts is typed as { host?: string; port?: number; verbose?: boolean }
    console.log(opts.host, opts.port, opts.verbose)
  })

program.parse(process.argv)

Option Name Format

Option names must follow --foo or --foo-bar format. Kebab-case names are automatically converted to camelCase in the action callback:

.option('--output-dir', 'Output directory', String)
.option('--max-retries', 'Max retries', Number)
.action((opts) => {
  console.log(opts.outputDir)  // not opts['output-dir']
  console.log(opts.maxRetries) // not opts['max-retries']
})

Pre-built Commands

You can also create a Command instance separately and register it:

import { Command, Program } from '@jiakun-zhao/cli'

const buildCmd = new Command('build', 'Build the project')
buildCmd
  .option('--minify', 'Minify output', Boolean)
  .option('--target', 'Build target', String)
  .action((opts) => {
    console.log(opts.minify, opts.target)
  })

const program = new Program({ name: 'mycli', version: '1.0.0', description: '...' })
program.command(buildCmd)

program.parse(process.argv)

Type Validation

Option names and types are validated at both compile time and runtime:

// Compile error: name must start with '--'
.option('host', 'Host', String)

// Compile error: type must be String, Number, or Boolean
.option('--host', 'Host', Array)

// Runtime error: invalid name format
.option('--Host', 'Host', String)      // must be lowercase
.option('--host name', 'Host', String) // no spaces allowed

Help Output

Running with --help or -h prints:

mycli - A CLI tool (v1.0.0)

Commands:
  deploy production   Deploy to production

Options:
  --help              Show help
  --version           Show version
  --host              Server host
  --port              Server port
  --verbose           Verbose output

Running with --version or -v prints:

mycli v1.0.0

API

new Program(config)

| Parameter | Type | Description | | -------------------- | -------- | ------------------- | | config.name | string | CLI program name | | config.version | string | Program version | | config.description | string | Program description |

program.command(name, description)

Register a command. Returns a Command instance for chaining.

program.command(cmd)

Register a pre-built Command instance.

command.option(name, description, type)

Register an option. Chainable.

| Parameter | Type | Description | | ------------- | ----------------------------- | -------------------------------------------------- | | name | `--${string}` | Option name, must be --foo or --foo-bar format | | description | string | Option description | | type | String \| Number \| Boolean | Value type |

command.action(handler)

Set the action handler. handler receives an object with parsed option values.

program.parse(argv)

Parse process.argv and execute the matched command's action. Returns a Promise.

License

MIT