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

argue-cli

v3.2.0

Published

A thin and strongly typed CLI arguments parser for Node.js.

Readme

argue-cli

ESM-only package NPM version Node version Dependencies status Install size Build status Coverage status

A thin and strongly typed CLI arguments parser for Node.js.

Usage

  1. Install
# pnpm
pnpm add argue-cli
# yarn
yarn add argue-cli
# npm
npm i argue-cli
  1. Import in your code and use it!
import { read, end, expect, alias, option, readOptions } from 'argue-cli'

/**
 * Expect and read one of the commands
 */
const command = expect(
  alias('install', 'i'),
  'remove'
)
let options = {}

if (command === 'install') {
  /**
   * Read passed options
   */
  options = readOptions(
    option(alias('save', 'S'), Boolean),
    option(alias('saveDev', 'save-dev', 'D'), Boolean),
    option('workspace', String)
  )
}

/**
 * Read next argument
 */
const packageName = read()

/**
 * Expect end of the arguments
 */
end()

/* ... */

API

Argue reads arguments sequentially from an internal state, which is initialized with process.argv. Every call consumes the arguments it reads, so you describe your CLI step by step: expect a command, read its options, read positional arguments, and finally assert the end.

[!TIP] The internal state can be controlled manually with setArgs(...args) and resetArgs() — handy in tests.

read

function read(): string

Reads the next argument and returns it. Throws an error if there are no arguments left.

// my-cli sort-imports
const fileName = read() // 'sort-imports'

rest

function rest(): string[]

Reads all remaining arguments and returns them. Returns an empty array if there are none — unlike read, it never throws.

// my-cli format a.js b.js c.js
expect('format')

const files = rest() // ['a.js', 'b.js', 'c.js']

end() // always passes after rest()

end

function end(): void

Asserts that all arguments were consumed. Throws an error if there are any arguments left — useful to catch typos and unexpected input.

// my-cli install --sav
expect('install')
readOptions(
  option(alias('save', 'S'), Boolean)
)
end() // throws: Unexpected argument "--sav"

expect

function expect(...argRefs: ArgRef[]): string

Expects the next argument to be one of the given ones and returns the matched name. If an alias matches, the main name is returned. Throws an error on any other input.

The return type is inferred as a union of the given names:

// my-cli i
const command = expect(alias('install', 'i'), 'remove')
// typeof command: 'install' | 'remove'
// command === 'install'

alias

function alias(name: string, ...aliases: string[]): AliasArgRef

Describes an argument that has alternative names. Use it anywhere an argument name is expected — in expect and option.

alias('install', 'i')
alias('saveDev', 'save-dev', 'D')

autocase

function autocase(argRef: ArgRef): ArgRef

Describes an argument that matches both camelCase and kebab-case forms. The name can be given in either form — the twin form is added as an alias. Aliases longer than one character are autocased too. Use it anywhere an argument name is expected.

autocase('firstRelease')
// --firstRelease and --first-release are both accepted

autocase(alias('save-dev', 'D'))
// --save-dev, --saveDev and -D

option

function option(argRef: ArgRef, type: OptionConstructor): OptionReader

Describes an option with a value of the given type, to be read by readOptions:

  • String — takes the next argument as a value: --workspace packages/app
  • Number — parses the next argument as a number: --port 8080
  • Boolean — a flag without a value, true when present: --verbose
  • Array — splits the next argument by commas; repeated options are merged: --plugins eslint,swc --plugins tsc['eslint', 'swc', 'tsc']
  • [String] or [Number] — takes the next argument as a whole; repeated options are collected: --match '*.{js,ts}' --match '*.css'['*.{js,ts}', '*.css']. Use it instead of Array for values that may contain commas of their own

flag

function flag(argRef: ArgRef): OptionReader

Describes a boolean flag with --no-* negation support, to be read by readOptions: --verbose sets true, --no-verbose sets false. Use option(argRef, Boolean) when negation is not wanted.

const options = readOptions(
  flag(autocase('firstRelease'))
)
// --first-release → { firstRelease: true }
// --no-first-release, --no-firstRelease → { firstRelease: false }

readOptions

function readOptions(...optionReaders: OptionReader[]): OptionResult

Scans the arguments and reads all described options. Both --option and -o prefixes are accepted, and a value can be passed either as the next argument or inline: --workspace packages/app and --workspace=packages/app are equivalent. Arguments that don't match any described option are left untouched, so you can continue reading them afterwards.

The result is a strongly typed object, where every property is optional — an option simply may not be passed:

// my-cli --save-dev --workspace packages/app my-package
const options = readOptions(
  option(alias('saveDev', 'save-dev', 'D'), Boolean),
  option('workspace', String)
)
// typeof options: { saveDev?: boolean, workspace?: string }
// options: { saveDev: true, workspace: 'packages/app' }

const packageName = read() // 'my-package'

TypeScript

In the API section types are described in a simplified way. A detailed example of the inferred types you can see in type tests.