Help and version
The generated help screens, where their text comes from, and how --help and --version behave.
zodline generates both help screens from what you already declared: meta, command descriptions, schema
keys and .describe() text. There is nothing to keep in sync by hand.
Meta
meta supplies the CLI’s own identity:
export const config = defineConfig({
meta: {
name: 'my-cli',
version: '1.0.0',
description: 'A simple example CLI',
},
commands: { greet, copy },
});
name?string
Used in usage lines and the per-command help hint. Falls back to "cli".
stringversion?string
Printed by --version. Without it, --version does nothing.
stringdescription?string
One-line summary above the usage line.
stringThe command list
my-cli --help, or running the CLI with no command and no defaultCommand:
A simple example CLI (my-cli v1.0.0)
USAGE my-cli greet|copy
COMMANDS
greet Greet someone
copy Copy a file to another location
Use my-cli <command> --help for more information about a command.
Commands appear in the order they are declared in commands, each with its description.
Per-command help
my-cli greet --help:
Greet someone (my-cli greet v1.0.0)
USAGE my-cli greet [OPTIONS]
OPTIONS
--name, -n Name to greet
--loud, -l Use uppercase (default: false)
Each line is built from the schema:
- the long form is the schema key in kebab-case
- the short form comes from the alias map
- the description is the option’s
.describe()text (default: …)is read off.default(), including through an.optional()wrapper
[OPTIONS] appears only when the command declares options; [ARGS] only when it declares an args schema.
Version
my-cli --version
# 1.0.0
--version is only handled when no command name was given and meta.version is set. my-cli greet --version is treated as a flag on greet, not as a version request.
Behaviour
| Invocation | Result |
|---|---|
my-cli --help |
Prints the command list, then exits with code 0. |
my-cli <command> --help |
Prints that command’s options, then exits with code 0. |
my-cli --version |
Prints meta.version, then exits with code 0. |
my-cli <unknown> |
Prints the command list, then throws ZodlineError. |
my-cli (no defaultCommand) |
Prints the command list, then throws ZodlineError. |
What is not built in
-hand-vare not registered. They are rejected as unknown options unless you map them yourself with an alias.helpas a subcommand (my-cli help greet) does not exist. Add it tocommandsif you want it.- Colors are always emitted as ANSI escape codes; there is no flag to disable them.
Next: Error handling
Which failures throw what, and how to report them.