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

cli-controller

v0.1.0

Published

> `npm install cli-controller`

Readme

Super simple CLI controller

npm install cli-controller

Make a proper CLI out of it using the "bin" field in package.json

Examples

Most basic form

To create a cli like this:

node ./index.js hello

write the following index.js.

// index.js
const { Cli } = require('cli-controller')

new Cli().route('hello', () => 'world').serve()

Arguments and flags

node ./index.js make something amazing --please --v=1 --hey=you
// index.js
const { Cli } = require('cli-controller')

new Cli()
  .route('make', ({ args, flags }) => {
    console.log(args) // ['something', 'amazing']
    console.log(flags) // { please: true, v: 1, hey: 'you' }
  })
  // .route('hello', () => 'world') <-- you can chain `.route`
  .serve()

Default callback when no argument is passed (excluding flags)

node ./index.js
// index.js
const { Cli } = require('cli-controller')

new Cli()
  // .route('hello', () => 'world')
  .default(({ flags }) => {
    console.log('default!')
  })
  .serve()

If default it's not specified, a list of available routes will be printed to the console.

Cleaner API with params

Consider the code for the following CLI node ./index.js build my-app

new Cli()
  .route('build', ({ args }) => {
    const [project] = args
  })
  .serve()

It can be expressed much clearer using params:

new Cli()
  .route('build {project}', ({ params }) => {
    console.log(params) // { project: 'my-app' }
  })
  .serve()

If the parameter is not specified, it will raise an exception. You can mark params optional like so:

new Cli()
  .route('build {project?}', ({ params }) => {})
  .serve()

Group routes

Group common routes together to create the following API:

node ./index.js db:migrate
node ./index.js db:dump
new Cli()
  .group('db', group => {
    group.route('migrate', context => {})
    group.route('dump', context => {})
  })
  .serve()

Fallback when route was not found

By default, it will raise an exception optionally providing some alternative routes.

node ./index.js does-not-exist
// index.js
const { Cli } = require('cli-controller')

new Cli()
  .fallback(({ name, args, flags }) => {
    console.log('not found!', name)
  })
  .serve()

Alternative API

You don't need an endless chain if you don't want! This is also possible:

const cli = new Cli()

cli.route('build {project}', (context) => {})

cli.serve()

Document your API

You can add a description to your API so they appear like below when calling the CLI with the -h or --help flag ...

node ./index.js -h
# Command Line Interface for Something Awesome!
#
# make {project} - Make something awesome

... as well as like below for individual routes.

node ./index.js make -h
# make {project} - Make something awesome
const cli = new Cli().description('Command Line Interface for Something Awesome!')

cli.route('build {project}', (context) => {}, { description: 'Make something awesome' })

cli.serve()