Installation
Install zodline and its Zod peer dependency, and check the runtime requirements.
zodline needs Zod v4 alongside it. Zod is a peer dependency, so install both:
npm install zodline zodpnpm add zodline zodyarn add zodline zodbun add zodline zodRequirements
Node?string
Uses only standard library APIs.
string>= 16Module?string
Package "type": "module". No CommonJS build.
stringESMZod?string
Peer dependency. Provide it yourself.
string^4.0.0Dependencies?string
No runtime dependencies beyond the Zod peer.
string0Import
Everything is exported from the package root:
import {
defineCommand,
defineConfig,
defineOptions,
processConfig,
ZodlineError,
} from 'zodline';
Types are exported as well:
import type {
CommandDefinition,
DefineConfig,
OptionsDefinition,
ProcessResult,
} from 'zodline';
ESM only
zodline ships as ES modules with no CommonJS build. In a Node.js project, either set "type": "module" in
your package.json or use the .mjs extension for your entry file.
Make it executable
A CLI is a file with a shebang, wired up through the bin field:
#!/usr/bin/env node
import { processConfig } from 'zodline';
import { config } from './config.js';
const result = processConfig(config, process.argv.slice(2));
await result.command.action(result.options, result.args);
{
"type": "module",
"bin": {
"my-cli": "./cli.js"
}
}
Continue to the Quickstart
Define your first command, parse argv, and run it.