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

node-autocli

v0.1.6

Published

Generates and handles a complete CLI for your node.js program by parsing the JS Doc.

Downloads

7

Readme

AutoCLI

This is alpha stage software, feedback welcome

When building CLIs for testing and admin of my code I often found that I had to repeat a lot of code. More importantly, I found that I wrote roughly the same texts both in JS Docs as in the help output of CLI commands.

AutoCLI is a small library with single function call that will generate a complete CLI for your Node.js project. It just needs to know what source files it should parse for JSDoc, and it will use that to build a model for what commands (functions) can be called, their names, description and accepted parameters. AutoCLI only works if your source code uses proper JS Doc!

Similar to: Python Fire, Python Typer

How it works

Using the excellent jsdoc-api package we can scan Javascript source files for JS Doc comments. Let's say you have this function:

// math.js
/**
 *	Adds two numbers.
 *
 * @param {number} a first number
 * @param {number} b second number
 * @returns {number}
 */
exports.adder = function (a, b) {
    return a+b;
}

Let's say your entry point script is:

// index.js
const { autoCLI } = require('node-autocli');

if (require.main === module) {
    await autoCLI(process.argv, 'math.js');
}

If you call node index.js adder <a> <b> it will run the function and output the result, or if you type something wrong, it will give you a help screen.

Features

  • Generates a nice-looking automated help and version commands that lists all commands, plus top-level CLI information like description and version pulled from your package.json
  • Prints help and parameters, including type and defaults, for individual commands
  • Can handle a flat list of commands or commands nested into command groups
  • Tries to guess which command the user intended if it can't find what was typed
  • Can be provided an object of internal arguments that will be populated in code and not exposed to CLI users, so that you don't need to maintain different versions of your function
  • Can take arguments as JSON encoded text or path to a JSON file
  • If provided JSON is an array, it will run the command for each element, so it becomes a simple batch runner for commands

Planned features

  • Automatically convert input arguments to correct type using JS Dcc parameter types
  • Better error messages for improper JS Doc
  • Fall back on parsing function signatures if no JS Doc available
  • JSON from stdin
  • Return a list of promises
  • Utilize environment variables
  • Correctly return exit codes
  • BASH completions

Documentation

/**
 * Automatically generates a CLI for given sourcePaths with exported and
 * documented functions. Executes the command and options provided via the argv
 * array.
 *
 * @param {string[]} argv array of command options from `process.argv` 
 * @param {string|string[]|object} sourcePaths path(s) of source files to scan.
 * If an object, each key will denote a group of commands.
 * @param {object} [options={}] the options object
 * @param {string} options.cliName name of the CLI app to display when printing
 * help. Defaults to package.json values from calling module.
 * @param {string} options.cliDescription description of the CLI app to display
 * when printing help. Defaults to package.json values from calling module.
 * @param {string} options.cliVersion version of the CLI app to display when
 * printing help. Defaults to package.json values from calling module.
 * @param {object} options.minimistOpts specific options to minimist that is
 * used to parse command arguments
 * @param {object} options.internalArgs function parameters that should not be
 * exposed in CLI commands but instead populated internally
 * @param {boolean} [options.parallelize=true] if given multiple commands (with
 * -j), run them in parallel
 * @returns {Promise<any[]>} resolving to an array of command return values
 */