Skip to content
clibuilder icon

clibuilder

Build a command line application out of typed commands, config files, and plugins.

clibuilder builds command line applications from commands. Each command declares its own arguments and options with the t type descriptors, and its config with any Standard Schema. The types of what run() receives are inferred from those declarations — no separate type definition to keep in sync.

import { cli, t } from 'clibuilder'
cli({ name: 'greet', version: '1.0.0' })
.default({
arguments: [{ name: 'name', description: 'who to greet' }],
options: { times: { description: 'how many times', type: t.int(), default: 1 } },
run(args) {
// args.name is string, args.times is number
for (let i = 0; i < args.times; i++) this.ui.info(`hello, ${args.name}`)
}
})
.parse(process.argv)
.catch(e => process.exit(e?.code || 1))
Terminal window
npm install clibuilder

See Installation for other package managers, then walk through Your First CLI.