# JavaScript CLI libraries

JavaScript CLI libraries turn the arguments typed after a command into options, flags, and handler calls inside a Node.js program. A parser reads that argument list and checks it against the commands and options the program declares. These libraries define the commands of build tools, deploy scripts, and code generators that developers and coding agents run from a terminal.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [Commander](#commander) | 2.9B | 28.5K | Nov 2026 | MIT |
| [yargs](#yargs) | 1.5B | 11.5K | Sep 2026 | MIT |
| [argparse](#argparse) | 1.4B | 516 | Oct 2026 | PSF-2.0 |
| [CAC](#cac) | 265.6M | 3.1K | Oct 2026 | MIT |
| [Meow](#meow) | 193.8M | 3.7K | Feb 2026 | MIT |
| [Citty](#citty) | 190.8M | 1.4K | Apr 2026 | MIT |
| [@oclif/core](#oclif-core) | 63.4M | 321 | Nov 2026 | MIT |
| [Sade](#sade) | 57.5M | 1.1K | Jan 2022 | MIT |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[Commander](#commander) has the most monthly downloads in this comparison, at 2.9B.

## Capabilities

| Library | Command-specific schemas | Async handler result |
| --- | --- | --- |
| [Commander](#commander) | Yes | Yes |
| [yargs](#yargs) | Yes | Yes |
| [argparse](#argparse) | Yes | No |
| [CAC](#cac) | Yes | Yes |
| [Meow](#meow) | No | No |
| [Citty](#citty) | Yes | Yes |
| [@oclif/core](#oclif-core) | Yes | Yes |
| [Sade](#sade) | Yes | Yes |

## Libraries

### Commander

[GitHub](https://github.com/tj/commander.js) · [npm](https://www.npmjs.com/package/commander) · [Docs](https://raw.githubusercontent.com/tj/commander.js/master/Readme.md)

Builds command trees with options, argument validation, action handlers, and generated help.

- Downloads / mo: 2.9B
- Stars: 28.5K
- Last release: 15.1.0
- License: MIT
- Capabilities: [From the Commander docs](https://raw.githubusercontent.com/tj/commander.js/master/Readme.md)

**Strengths**

- **Builds nested command trees.** Define subcommands and their own arguments, options, and handlers.
- **Rejects missing required options.** Use requiredOption when a named option must be supplied.

**Watch out for**

- **Async actions need asynchronous parsing.** Call parseAsync when any action handler is asynchronous.
- **Strong option inference needs extras.** Install extra-typings to infer action parameters and parsed option types.

```sh
npm install commander@15.1.0
```

**Quickstart**

```typescript
import { Command } from "commander";
const cli = new Command();
cli.option("--name <name>").parse(["node", "hello", "--name", "Ada"]);
console.log(cli.opts().name);

```

From [Readme.md](https://raw.githubusercontent.com/tj/commander.js/master/Readme.md) · [Find projects using Commander →](https://dashboard.exa.ai/playground/search?q=JavaScript%20applications%20using%20commander%20to%20build%20command%20trees%2C%20validate%20flags%2C%20configure%20help%20and%20execute%20asynchronous%20commands&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

### yargs

[GitHub](https://github.com/yargs/yargs) · [npm](https://www.npmjs.com/package/yargs) · [Docs](https://raw.githubusercontent.com/yargs/yargs/main/docs/api.md)

Parses command-line arguments with command modules, validation, and configurable value coercion.

- Downloads / mo: 1.5B
- Stars: 11.5K
- Last release: 18.2.0
- License: MIT
- Capabilities: [From the yargs docs](https://raw.githubusercontent.com/yargs/yargs/main/docs/api.md)

**Strengths**

- **Transforms option values during parsing.** Use coerce to transform values or reject invalid inputs.
- **Requires named flags explicitly.** Use demandOption for flags that every invocation needs.

**Watch out for**

- **Numeric-looking strings are converted.** Declare string options to preserve leading-zero identifiers.
- **Directory discovery flattens commands.** Register nested command trees explicitly.

```sh
npm install yargs@18.2.0
```

**lerna/lerna** (36.0K stars)

[lerna/lerna](https://github.com/lerna/lerna) 

```typescript
export function lernaCLI(argv?: string | readonly string[], cwd?: string) {
  const cli = yargs(argv, cwd);

  return globalOptions(cli)
    .usage("Usage: $0 <command> [options]")
    .demandCommand(1, "A command is required. Pass --help to see all available commands and options.")
    .recommendCommands()
    .strict()
    .fail((msg: string, err: any) => {
      // certain yargs validations throw strings :P
      const actual = err || new Error(msg);

      // ValidationErrors are already logged, as are package errors
      if (actual.name !== "ValidationError" && !actual.pkg) {
        // the recommendCommands() message is too terse
        if (/Did you mean/.test(actual.message)) {
          // TODO: refactor to address type issues
          // eslint-disable-next-line @typescript-eslint/ban-ts-comment
          // @ts-ignore
          log.error("lerna", `Unknown command "${cli.parsed.argv._[0]}"`);
        }

        log.error("lerna", actual.message);
      }

      // exit non-zero so the CLI can be usefully chained
      cli.exit(actual.exitCode > 0 ? actual.exitCode : 1, actual);
    })
    .alias("h", "help")
    .alias("v", "version")
    .wrap(cli.terminalWidth()).epilogue(dedent`
      When a command fails, all logs are written to lerna-debug.log in the current working directory.

      For more information, check out the docs at https://lerna.js.org/docs/introduction
    `);
}

```

[libs/core/src/lib/cli.ts](https://github.com/lerna/lerna/blob/2a7ecf27c271a8f0b3616b7d91bb76bab3344f01/libs/core/src/lib/cli.ts#L18) · [More projects using yargs →](https://dashboard.exa.ai/playground/search?q=JavaScript%20applications%20using%20yargs%20to%20build%20command%20trees%2C%20validate%20flags%2C%20configure%20help%20and%20execute%20asynchronous%20commands&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
import yargs from "yargs";
const argv = yargs(["--name", "Ada"]).option("name", { type: "string" }).parseSync();
console.log(argv.name);

```

From [README.md](https://raw.githubusercontent.com/yargs/yargs/main/docs/api.md)

### argparse

[GitHub](https://github.com/nodeca/argparse) · [npm](https://www.npmjs.com/package/argparse) · [Docs](https://raw.githubusercontent.com/nodeca/argparse/master/README.md)

Parses command-line arguments for Node.js with subcommands, as a port of Python's argparse.

- Downloads / mo: 1.4B
- Stars: 516
- Last release: 3.0.4
- License: PSF-2.0
- Capabilities: [From the argparse docs](https://raw.githubusercontent.com/nodeca/argparse/master/README.md)

**Watch out for**

- **No keyword arguments.** Pass an options object where Python argparse takes keyword arguments.

```sh
npm install argparse@3.0.4
```

**fontello/fontello** (7.1K stars)

[fontello/fontello](https://github.com/fontello/fontello) 

```javascript
function (N) {
  return Promise.resolve().then(() => {
    // main parser instance
    let argparser = new ArgumentParser({
      add_help: true,
      epilog:   'See \'%(prog)s <command> --help\' for ' +
                'more information on specific command.'
    });

    // sub-parser for commands
    let cmdArgparsers = argparser.add_subparsers({
      title:    'Known commands',
      metavar:  '<command>',
      dest:     'command'
    });

    // collect cli scripts

    let commands = {};

    N.apps.forEach(app => {
      let rootDir = path.join(app.root, 'cli');

      glob('**/*.js', {
        cwd: rootDir
      })
      .filter(name => !/^[._]|\\[._]|\/[_.]/.test(name))
      .forEach(name => {
        let cli = require(path.join(rootDir, name));
        let cmd = cli.commandName || path.parse(name).name;

        let subArgparser = cmdArgparsers.add_parser(cmd, cli.parserParameters || {});
        let args = cli.commandLineArguments || [];

        args.forEach(item => subArgparser.add_argument(...item.args, item.options || {}));

        // store command
        commands[cmd] = cli;
      });
    });

    if (Object.keys(commands).length === 0) {
      throw new Error("Can't find available CLI commands. Please, check config files.");
    }

    // by default (no params) - run server
    if (N.args.length === 0 && commands.server) {
      N.args.unshift('server');
    }

    let args = argparser.parse_args(N.args);

    // set process title
    process.title = 'nodeca-' + args.command;

    return commands[args.command].run(N, args);
  });
}

```

[lib/system/runner/exec_cli.js](https://github.com/fontello/fontello/blob/71330f51d11b00fa75b6c516db2ea4d62da67330/lib/system/runner/exec_cli.js#L20) · [More projects using argparse →](https://dashboard.exa.ai/playground/search?q=argparse%20GitHub%20projects)

**Quickstart**

```javascript
const { ArgumentParser } = require("argparse");
const parser = new ArgumentParser({ description: "Greeting input" });
parser.add_argument("--name");
console.log(parser.parse_args(["--name", "Ada"]).name);

```

From [README.md](https://raw.githubusercontent.com/nodeca/argparse/master/README.md)

### CAC

[GitHub](https://github.com/cacjs/cac) · [npm](https://www.npmjs.com/package/cac) · [Docs](https://raw.githubusercontent.com/cacjs/cac/main/README.md)

Builds small command-line interfaces with subcommands, variadic arguments, and nested option objects.

- Downloads / mo: 265.6M
- Stars: 3.1K
- Last release: 7.1.0
- License: MIT
- Capabilities: [From the CAC docs](https://raw.githubusercontent.com/cacjs/cac/main/README.md)

**Strengths**

- **Groups dotted options into objects.** Dot-nested flags are merged into one option object.
- **Supports variadic command arguments.** Collect multiple positional values with a variadic argument.

**Watch out for**

- **Commands need actions for validation.** Attach an action to enable action-command option checks.
- **Negated flags need explicit definitions.** Declare the no-prefixed option to accept false from the command line.

```sh
npm install cac@7.1.0
```

**egoist/tsup** (11.3K stars)

[egoist/tsup](https://github.com/egoist/tsup) 

```typescript
export async function main(options: Options = {}) {
  const cli = cac('tsup')

  cli
    .command('[...files]', 'Bundle files', {
      ignoreOptionDefaultValue: true,
    })
    .option('--entry.* <file>', 'Use a key-value pair as entry files')
    .option('-d, --out-dir <dir>', 'Output directory', { default: 'dist' })
    .option('--format <format>', 'Bundle format, "cjs", "iife", "esm"', {
      default: 'cjs',
    })
    .option('--minify [terser]', 'Minify bundle')
    .option('--minify-whitespace', 'Minify whitespace')
    .option('--minify-identifiers', 'Minify identifiers')
    .option('--minify-syntax', 'Minify syntax')
    .option(
      '--keep-names',
      'Keep original function and class names in minified code',
    )
    .option('--target <target>', 'Bundle target, "es20XX" or "esnext"', {
      default: 'es2017',
    })
    .option(
      '--legacy-output',
      'Output different formats to different folder instead of using different extensions',
    )
    .option('--dts [entry]', 'Generate declaration file')
    .option('--dts-resolve', 'Resolve externals types used for d.ts files')
    .option('--dts-only', 'Emit declaration files only')
    .option(
      '--experimental-dts [entry]',
      'Generate declaration file (experimental)',
    )
    .option(
      '--sourcemap [inline]',
      'Generate external sourcemap, or inline source: --sourcemap inline',
    )
    .option(
      '--watch [path]',
      'Watch mode, if path is not specified, it watches the current folder ".". Repeat "--watch" for more than one path',
    )
    .option('--ignore-watch <path>', 'Ignore custom paths in watch mode')
    .option(
      '--onSuccess <command>',
      'Execute command after successful build, specially useful for watch mode',
    )
    .option('--env.* <value>', 'Define compile-time env variables')
    .option(
      '--inject <file>',
      'Replace a global variable with an import from another file',
    )
    .option('--define.* <value>', 'Define compile-time constants')
    .option(
      '--external <name>',
      'Mark specific packages / package.json (dependencies and peerDependencies) as external',
    )
    .option('--global-name <name>', 'Global variable name for iife format')
    .option('--jsxFactory <jsxFactory>', 'Name of JSX factory function', {
      default: 'React.createElement',
    })
    .option('--jsxFragment <jsxFragment>', 'Name of JSX fragment function', {
      default: 'React.Fragment',
    })
    .option('--replaceNodeEnv', 'Replace process.env.NODE_ENV')
    .option('--no-splitting', 'Disable code splitting')
    .option('--clean', 'Clean output directory')
    .option(
      '--silent',
      'Suppress non-error logs (excluding "onSuccess" process output)',
    )
    .option('--pure <express>', 'Mark specific expressions as pure')
    .option('--metafile', 'Emit esbuild metafile (a JSON file)')
    .option('--platform <platform>', 'Target platform', {
      default: 'node',
    })
    .option('--loader <ext=loader>', 'Specify the loader for a file extension')
    .option('--tsconfig <filename>', 'Use a custom tsconfig')
    .option('--config <filename>', 'Use a custom config file')
    .option('--no-config', 'Disable config file')
    .option('--shims', 'Enable cjs and esm shims')
    .option('--inject-style', 'Inject style tag to document head')
    .option(
      '--treeshake [strategy]',
      'Using Rollup for treeshaking instead, "recommended" or "smallest" or "safest"',
    )
    .option('--publicDir [dir]', 'Copy public directory to output directory')
    .option(
      '--killSignal <signal>',
      'Signal to kill child process, "SIGTERM" or "SIGKILL"',
    )
    .option('--cjsInterop', 'Enable cjs interop')
    .action(async (files: string[], flags) => {
      const { build } = await import('.')
      Object.assign(options, {
        ...flags,
      })
      if (!options.entry && files.length > 0) {
        options.entry = files.map(slash)
      }
      if (flags.format) {
        const format = ensureArray(flags.format) as Format[]
        options.format = format
      }
      if (flags.external) {
        const external = ensureArray(flags.external)
        options.external = external
      }
      if (flags.target) {
        options.target = flags.target.includes(',')
          ? flags.target.split(',')
          : flags.target
      }
      if (flags.dts || flags.dtsResolve || flags.dtsOnly) {
        options.dts = {}
        if (typeof flags.dts === 'string') {
          options.dts.entry = flags.dts
        }
        if (flags.dtsResolve) {
          options.dts.resolve = flags.dtsResolve
        }
        if (flags.dtsOnly) {
          options.dts.only = true
        }
      }
      if (flags.inject) {
        const inject = ensureArray(flags.inject)
        options.inject = inject
      }
      if (flags.define) {
        const define: Record<string, string> = flatten(flags.define)
        options.define = define
      }
      if (flags.loader) {
        const loader = ensureArray(flags.loader)
        options.loader = loader.reduce((result, item) => {
          const parts = item.split('=')
          return {
            ...result,
            [parts[0]]: parts[1],
          }
        }, {})
      }
      await build(options)
    })

  cli.help()

  cli.version(version)

  cli.parse(process.argv, { run: false })
  await cli.runMatchedCommand()
}

```

[src/cli-main.ts](https://github.com/egoist/tsup/blob/198479b814f5981032dc0b7cd52c4b9e4b699ac3/src/cli-main.ts#L11) · [More projects using CAC →](https://dashboard.exa.ai/playground/search?q=JavaScript%20applications%20using%20cac%20to%20build%20command%20trees%2C%20validate%20flags%2C%20configure%20help%20and%20execute%20asynchronous%20commands&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```typescript
import { cac } from "cac";
const cli = cac("hello");
const parsed = cli.option("--name <name>", "Name").parse(["node", "hello", "--name", "Ada"]);
console.log(parsed.options.name);

```

From [README.md](https://raw.githubusercontent.com/cacjs/cac/main/README.md)

### Meow

[GitHub](https://github.com/sindresorhus/meow) · [npm](https://www.npmjs.com/package/meow) · [Docs](https://raw.githubusercontent.com/sindresorhus/meow/main/readme.md)

Parses arguments and flags and prints the supplied help text on --help.

- Downloads / mo: 193.8M
- Stars: 3.7K
- Last release: 14.1.0
- License: MIT
- Capabilities: [From the Meow docs](https://raw.githubusercontent.com/sindresorhus/meow/main/readme.md)

**Strengths**

- **Converts flags to camelCase.** Flag names arrive as camelCase keys in the parsed result.

```sh
npm install meow@14.1.0
```

**stylelint/stylelint** (11.6K stars)

[stylelint/stylelint](https://github.com/stylelint/stylelint) 

```javascript
export function buildCLI(argv) {
	return meow(helpText, {
		autoHelp: false,
		autoVersion: false,
		argv,

		// NOTE: `meow()` infers flag types when passing a flag object with inline.
		// However, `checkInvalidCLIOptions()` also needs this flag object.
		// So, unfortunately, the return value type inference by `meow()` is unavailable here.
		//
		// @ts-expect-error -- TS2322: Type '{ allowEmptyInput: {...} }' is not assignable to type 'AnyFlags'.
		flags,

		// NOTE: We must enable `allowUnknownFlags` because meow exits with `2` if `allowUnknownFlags` is disabled.
		// Instead, we use our different exit code with `checkInvalidCLIOptions()`.
		// See also https://github.com/sindresorhus/meow/blob/v12.0.1/source/validate.js#L75
		allowUnknownFlags: true,

		// NOTE: If CLI flags are unspecified (e.g., `--cache` nor `--no-cache`), we want to fall back to config properties (e.g., `cache`).
		booleanDefault: undefined,

		importMeta: import.meta,
	});
}

```

[lib/cli.mjs](https://github.com/stylelint/stylelint/blob/b96814344b7d1088e3459c44dcafebfbdabff412/lib/cli.mjs#L725) · [More projects using Meow →](https://dashboard.exa.ai/playground/search?q=meow%20GitHub%20projects)

**Quickstart**

```javascript
import meow from "meow";
const cli = meow("Usage: hello --name <name>", {
  importMeta: import.meta,
  argv: ["--name", "Ada"],
  flags: { name: { type: "string" } },
});
console.log(cli.flags.name);

```

From [readme.md](https://raw.githubusercontent.com/sindresorhus/meow/main/readme.md)

### Citty

[GitHub](https://github.com/unjs/citty) · [npm](https://www.npmjs.com/package/citty) · [Docs](https://raw.githubusercontent.com/unjs/citty/main/README.md)

Builds command-line apps from command definitions with nested, lazily loaded subcommands.

- Downloads / mo: 190.8M
- Stars: 1.4K
- Last release: 0.2.2
- License: MIT
- Capabilities: [From the Citty docs](https://raw.githubusercontent.com/unjs/citty/main/README.md)

**Strengths**

- **Built on util.parseArgs.** Parsing runs on Node's native util.parseArgs with no dependencies.

```sh
npm install citty@0.2.2
```

**heygen-com/hyperframes** (86.9K stars)

[heygen-com/hyperframes](https://github.com/heygen-com/hyperframes) 

```javascript
export async function showUsage(
  cmd: CommandDef,
  parent?: CommandDef,
  print: (text: string) => void = console.log,
): Promise<void> {
  if (!parent) {
    print(renderRootHelp() + "\n");
    return;
  }

  const meta = await (typeof cmd.meta === "function" ? cmd.meta() : cmd.meta);
  const usage = await renderUsage(cmd, parent);
  print((isColorSupported ? usage : stripVTControlCharacters(usage)) + "\n");

  const name = meta?.name;
  if (name) {
    const parentMeta = await (typeof parent.meta === "function" ? parent.meta() : parent.meta);
    const parentName = parentMeta?.name;
    const examples = STATIC_EXAMPLES[name] ?? (await loadExamples(name, parentName));
    if (examples) {
      print(formatExamples(examples) + "\n");
    }
  }
}

```

[packages/cli/src/help.ts](https://github.com/heygen-com/hyperframes/blob/6bd0b5d870ef197b1ff6d3d50d17944444c31a8f/packages/cli/src/help.ts#L225) · [More projects using Citty →](https://dashboard.exa.ai/playground/search?q=citty%20GitHub%20projects)

**Quickstart**

```javascript
import { defineCommand, runMain } from "citty";
const main = defineCommand({
  meta: { name: "hello" },
  args: { name: { type: "string", default: "Ada" } },
  run({ args }) { console.log(`Hello ${args.name}`); },
});
await runMain(main);

```

From [README.md](https://raw.githubusercontent.com/unjs/citty/main/README.md)

### @oclif/core

[GitHub](https://github.com/oclif/core) · [npm](https://www.npmjs.com/package/@oclif/core) · [Docs](https://raw.githubusercontent.com/oclif/core/main/README.md)

Provides a framework for single-command and multi-command CLIs, built out of the Salesforce CLI.

- Downloads / mo: 63.4M
- Stars: 321
- Last release: 5.1.12
- License: MIT
- Capabilities: [From the @oclif/core docs](https://raw.githubusercontent.com/oclif/core/main/README.md)

```sh
npm install @oclif/core@5.1.12
```

**NVIDIA/NemoClaw** (23.1K stars)

[NVIDIA/NemoClaw](https://github.com/NVIDIA/NemoClaw) 

```javascript
export async function runOclifCommandById(
  commandId: string,
  args: string[],
  opts: OclifCommandRunOptions,
): Promise<void> {
  const config = await OclifConfig.load(opts.rootDir);
  applyBrandedBin(config, opts.publicSandboxName);
  const errorLine = opts.error ?? console.error;
  const exit = opts.exit ?? ((code: number) => process.exit(code));
  const originalArgv = process.argv;
  const nativeArgv = [...commandId.split(":"), ...args];
  process.argv = [originalArgv[0] ?? process.execPath, originalArgv[1] ?? CLI_NAME, ...nativeArgv];

  try {
    await config.runCommand(commandId, args);
  } catch (error) {
    const exitCode = getOclifExitCode(error);
    if (exitCode === 0) {
      // Only oclif's own ExitError(0) is an intentional graceful exit (e.g.
      // Command.exit(0) / --help — its message is the synthetic "EEXIT: 0",
      // which must stay silent). Keep that path at exit 0.
      if (isOclifExitError(error)) {
        process.exitCode = 0;
        return;
      }
      // #5974: any OTHER error that merely happens to carry oclif.exit === 0
      // is a genuine failure that bubbled out of a command's run(). #2666
      // stopped it being silently swallowed (exit 0 + empty output); here we
      // also refuse to report success for it — surface its message AND exit
      // non-zero so `$?` stays scriptable. Fall back to a generic line if
      // formatOclifError() returns empty so a blank message never reintroduces
      // the silent path.
      const message = formatOclifError(error) || "Command exited with no output.";
      errorLine(`  ${message}`);
      process.exitCode = 1;
      return;
    }

    if (isOclifParseError(error)) {
      errorLine(`  ${formatOclifError(error)}`);
      exit(exitCode ?? 1);
    }

    // NCQ #3180: oclif's Command.exit(code) throws an ExitError carrying
    // `oclif.exit`. Treat that as a graceful exit with the requested code
    // so we don't leak a raw `at Object.exit (... /@oclif/core/...)` stack
    // trace to the user. Other oclif error classes (e.g. RequiredArgsError)
    // are left to bubble up so oclif's own handler still prints them.
    if (isOclifExitError(error) && typeof exitCode === "number") {
      exit(exitCode);
    }

    throw error;
  } finally {
    process.argv = originalArgv;
  }
}

```

[src/lib/cli/oclif-runner.ts](https://github.com/NVIDIA/NemoClaw/blob/6f36feffb7a0f448194eafef3042e7ad47faa0de/src/lib/cli/oclif-runner.ts#L97) · [More projects using @oclif/core →](https://dashboard.exa.ai/playground/search?q=%40oclif/core%20GitHub%20projects)

**Quickstart**

```javascript
import { Args, Parser } from "@oclif/core";
const { args } = await Parser.parse(["Ada"], {
  args: { name: Args.string({ required: true }) },
});
console.log(args.name);

```

From [README.md](https://raw.githubusercontent.com/oclif/core/main/README.md)

### Sade

[GitHub](https://github.com/lukeed/sade) · [npm](https://www.npmjs.com/package/sade) · [Docs](https://raw.githubusercontent.com/lukeed/sade/master/readme.md)

Builds Node.js CLIs with git-like subcommands, option aliases, default values, and generated help text.

- Downloads / mo: 57.5M
- Stars: 1.1K
- Last release: 1.8.1
- License: MIT
- Capabilities: [From the Sade docs](https://raw.githubusercontent.com/lukeed/sade/master/readme.md)

```sh
npm install sade@1.8.1
```

**developit/microbundle** (8.1K stars)

[developit/microbundle](https://github.com/developit/microbundle) 

```javascript
handler => {
	const ENABLE_MODERN = process.env.MICROBUNDLE_MODERN !== 'false';

	const DEFAULT_FORMATS = ENABLE_MODERN ? 'modern,esm,cjs,umd' : 'esm,cjs,umd';

	const cmd = type => (str, opts) => {
		opts.watch = opts.watch || type === 'watch';

		opts.entries = toArray(str || opts.entry).concat(opts._);

		if (typeof opts.compress !== 'undefined') {
			// Convert `--compress true/false/1/0` to booleans:
			if (typeof opts.compress !== 'boolean') {
				opts.compress = opts.compress !== 'false' && opts.compress !== '0';
			}
		} else {
			// the default compress value is `true` for web, `false` for Node:
			opts.compress = opts.target !== 'node';
		}

		handler(opts);
	};

	let prog = sade('microbundle');

	prog
		.version(version)
		.option('--entry, -i', 'Entry module(s)')
		.option('--output, -o', 'Directory to place build files into')
		.option(
			'--format, -f',
			`Only build specified formats (any of ${DEFAULT_FORMATS} or iife)`,
			DEFAULT_FORMATS,
		)
		.option('--watch, -w', 'Rebuilds on any change', false)
		.option(
			'--pkg-main',
			'Outputs files analog to package.json main entries',
			true,
		)
		.option('--target', 'Specify your target environment (node or web)', 'web')
		.option('--external', `Specify external dependencies, or 'none'`)
		.option('--globals', `Specify globals dependencies, or 'none'`)
		.example('--globals react=React,jquery=$')
		.option('--define', 'Replace constants with hard-coded values')
		.example('--define API_KEY=1234')
		.option('--alias', `Map imports to different modules`)
		.example('--alias react=preact')
		.option(
			'--compress',
			'Compress output using Terser (default true when --target is web, false when --target is node)',
		)
		.example('build --target web --no-compress')
		.option('--strict', 'Enforce undefined global context and add "use strict"')
		.option('--name', 'Specify name exposed in UMD builds')
		.option('--cwd', 'Use an alternative working directory', '.')
		.option('--sourcemap', 'Generate source map')
		.example("watch --no-sourcemap # don't generate sourcemaps")
		.option('--raw', 'Show raw byte size', false)
		.option('--jsx', 'A custom JSX pragma like React.createElement', 'h')
		.option(
			'--jsxFragment',
			'A custom JSX fragment pragma like React.Fragment',
			'Fragment',
		)
		.option(
			'--jsxImportSource',
			'Declares the module specifier to be used for importing jsx factory functions',
		)
		.option('--tsconfig', 'Specify the path to a custom tsconfig.json')
		.example('build --tsconfig tsconfig.build.json')
		.option(
			'--generateTypes',
			'Whether or not to generate types , if `types` or `typings` is set in `package.json` then it will default to be `true`',
		)
		.option('--css', 'Where to output CSS: "inline" or "external"', 'external')
		.option(
			'--css-modules',
			'Turns on css-modules for all .css imports. Passing a string will override the scopeName. eg --css-modules="_[hash]"',
			null,
		)
		.option(
			'--workers',
			'Bundle module workers - see https://github.com/surma/rollup-plugin-off-main-thread#auto-bundling',
			false,
		)
		.option(
			'--visualize',
			'Generate bundle makeup visualization (stats.html)',
			false,
		);

	prog
		.command('build [...entries]', '', { default: true })
		.describe('Build once and exit')
		.action(cmd('build'));

	prog
		.command('watch [...entries]')
		.describe('Rebuilds on any change')
		.action(cmd('watch'));

	// Parse argv; add extra aliases
	return argv =>
		prog.parse(argv, {
			alias: {
				o: ['output', 'd'],
				i: ['entry', 'entries', 'e'],
				w: ['watch'],
			},
			boolean: ['generateTypes'],
		});
}

```

[src/prog.js](https://github.com/developit/microbundle/blob/9f56e06b0d1d412f3f0aa4c94d332e77791dd09b/src/prog.js#L6) · [More projects using Sade →](https://dashboard.exa.ai/playground/search?q=sade%20GitHub%20projects)

**Quickstart**

```javascript
import sade from "sade";
sade("hello <name>")
  .action(name => console.log(`Hello ${name}`))
  .parse(["node", "hello", "Ada"]);

```

From [readme.md](https://raw.githubusercontent.com/lukeed/sade/master/readme.md)

## FAQ

### Which JavaScript CLI library should I use?

[Commander](#commander) builds command trees with options, handlers, and generated help, and it has the most monthly downloads, at 2.9B. [yargs](#yargs) adds value coercion and validation, while [oclif](#oclif-core) organizes larger CLIs as command classes with plugins.

### What is Commander.js?

[Commander](#commander) is a Node.js library for command-line programs. It defines commands, options, and action handlers, then parses the command line and prints generated help.

### Yargs vs Commander: which should I use?

Commander defines command trees with a fluent API and needs `parseAsync` for asynchronous actions. yargs converts and validates option values during parsing with `coerce` and `demandOption`.

### Oclif vs Commander: which should I use?

oclif builds class-based CLIs with command discovery and plugins, the structure behind the Salesforce CLI. Commander keeps commands in one fluent program definition.

### How does Commander wait for asynchronous actions?

Use parseAsync instead of parse when an action handler is asynchronous.

### How can yargs preserve leading zeros in identifiers?

Declare the relevant key with string to prevent numeric or boolean interpretation.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript CLI libraries Commander yargs CAC Clipanion code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
