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 🙏

© 2025 – Pkg Stats / Ryan Hefner

commander-extended

v0.1.1

Published

Additional features for Commander.js

Downloads

7

Readme

commander-extended

commander-extended adds a few new features to Commander. At the moment, only:

  • Option groups
    Instead of all options going under a single Options heading, you can create multiple named groups of options, each with their own descriptions.
  • Add multiple options to a command at once
    Now you can add multiple Option instances at once to a command using the new addOptions method.

Installation

Commander v13 is a peer depency, so it has to be installed separately:

npm i commander@13 commander-extended

commander-extended is written in TypeScript, so typings come along for free.

Using with other versions of commander

Since this mucks around in the private guts of Commander's help generation, different major versions will almost certainly break it and minor versions have a decent chance to. As this was made primarily for personal use I provide no guarantees that it'll be kept up to date with Commander's development, or that older versions of Commander will ever be supported. It's probably best to pin your Commander version to avoid unexpected problems. At time of writing, the current version of Commander, and the one commander-extended has been built against, is 13.1.0.

Usage

commander-extended extends the base Command class from Commander. To use its features, simply replace any imports of Command from Commander with one from commander-extended:

// old
import { Command, Option } from "commander";

// new
import { Command } from "commander-extended";
import { Option } from "commander";

Since it extends the base Command, it should be a drop-in replacement with no additional changes needed.

Option groups

import { Command, OptionGroup } from "commander-extended";
import { Option } from "commander";

const program = new Command("my-command")
  .description("Look, we're adding option groups!")
  .optionGroup("Output Options", "These options are used to control output.",
    new Option("--json", "Output as JSON."),
    new Option("--yaml", "output as YAML."),
  )
  // or
  .addOptionGroup(new OptionGroup("More Options")
    .description("This is another option group.")
    .addOption(new Option("--my-option", "This is my option."))
    .addOptions(
      new Option("--another-option", "Another option."),
      new Option("--yet-another-option", "Yet another option."),
    )
  );

Running this command with --help will yield:

Usage: my-command [options]

Look, we're adding option groups!

Options:
  -h, --help            display help for command

Output Options:
  These options are used to control output.

  --json                Output as JSON.
  --yaml                output as YAML.

More Options:
  This is another option group.

  --my-option           This is my option.
  --another-option      Another option.
  --yet-another-option  Yet another option.

Options within option groups are added to the command as usual, so you can use them exactly as if you had called addOption on the command directly.

Option groups are shown in the help in the order they were added. Ungrouped options always appear first, if any exist. The same is true for global options: all ungrouped options above the current command are aggregated into a single Global Options group, and all global groups are displayed below that, with Global prefixed to their header, e.g. the above Output Options group would become Global Output Options.

So, in summary, groups will appear like this, with the last two only appearing if showGlobalOptions is set:

Options:
[option-group-name]:
Global Options:
Global [option-group-name]:

Adding multiple options at once

A new method has been added to Command, addOptions, which accepts either an array of Option objects or any number of individual Option objects. It works exactly the same as calling addOption for each command individually.

import { Command } from "commander-extended";
import { Option } from "commander";

const program = new Command("my-command")
  .addOptions(
    new Option("--json", "Output as JSON."),
    new Option("--yaml", "output as YAML."),
  )