CAC (Command And Conquer) is a JavaScript library for building CLI apps with few APIs, subcommands, help text, and option validation.
Overview
CAC is a JavaScript library for creating command-line applications. It is marketed as lightweight with no dependencies beyond a single file, and written in TypeScript.
The core API centers on cli.option, cli.version, cli.help, and cli.parse for simple programs. It supports default commands, git-style subcommands, required option and argument checks, variadic arguments, dot-nested options, generated help output, and global error handling hooks.
Command-level options are validated when a command runs, with errors for unknown flags unless allowUnknownOptions is set. Kebab-case flags map to camelCase property names in parsed options. Bracket syntax in command names marks required or optional arguments, and negated options can pair with --no- flags for boolean settings.
The FAQ notes similarity to Commander.js but highlights dot-nested options such as --env.API_SECRET and the ability to allow unknown options on commands when configured.
Key features
- Single-file CLI framework
- Global and per-command options
- Git-style subcommands
- Automated help and version output
- Variadic and dot-nested options
- Option validation with allowUnknownOptions
- TypeScript-authored API
- Default command when none matches
Use cases
- Node.js CLI tooling
- Subcommand-based developer utilities
- Parsed argv with help and version flags