API Reference
clibuilder has a small surface. Everything below is a named export of the package root:
import { cli, command, testCommand, parseArgv, z } from 'clibuilder'Functions
Section titled “Functions”| Export | Purpose |
|---|---|
cli() |
Create the CLI builder — the entry point of every application |
command() |
Identity helper that types a standalone command object |
testCommand() |
Run a command in-process and capture its result and messages |
defineKey() / defineCollectionKey() |
Create typed plugin registry keys |
parseArgv() |
The raw argv tokenizer, exported for reuse |
enableCompileCache() |
Opt into Node’s V8 compile cache, from clibuilder/compile-cache |
isCliError() |
Whether a caught value is a CliError |
Values
Section titled “Values”| Export | Purpose |
|---|---|
z |
The zod instance used for every schema in the library |
exitCodes |
The codes the cli exits with — success, error, usage |
CliError |
Thrown from run() to fail the cli with a message and an exit code |
| Export | Purpose |
|---|---|
cli.Options |
Options accepted by cli() |
cli.UsageError |
One usage error found while parsing, as passed to onUsageError |
cli.UsageErrorHandler |
The signature of onUsageError, on cli() options and on a command |
cli.Command |
The shape of a command |
cli.Command.Argument |
A positional argument declaration |
cli.Command.Options |
The options record declaration |
UI |
The object on this.ui inside run() |
DisplayLevel |
'none' | 'info' | 'debug' | 'trace' |
PluginActivationContext |
What a plugin’s activate() receives |
Registry |
Read-only values and contributions available as this.registry in commands |
Most of the command types live under the cli namespace rather than at the top level, so you rarely
import them directly — command() infers them for you.