Skip to content

Options

Named -- arguments (or - for short forms). Declared in the options map of operation.

optionFlag — boolean toggle

Present or absent. Also accepts --flag=true / --flag=no.

ts
const verbose = optionFlag({
  long: "verbose",
  short: "v",
  description: "Enable verbose output",
});
// --verbose       →  true
// --verbose=yes   →  true
// --verbose=no    →  false
// (absent)        →  false
ParameterTypeDescription
longstringLong flag name (without --)
shortstring?Short flag name (without -)
descriptionstring?Help text
hintstring?Short note in parentheses
defaultboolean? Value when absent (default: false)
aliases{ longs?, shorts? }Additional names for the flag

A flag specified more than once triggers a parse error. Use

optionRepeatable if you need multiple values.

optionSingleValue — one typed value

Exactly one typed value.

ts
const output = optionSingleValue({
  long: "output",
  short: "o",
  type: typePath(),
  description: "Output directory",
  fallbackValueIfAbsent: () => "dist/",
});
// --output dist/   →  "dist/"
// --output=dist/   →  "dist/"
// -o dist/         →  "dist/"
// (absent)         →  "dist/"
ParameterTypeDescription
longstringLong option name
shortstring?Short option name
typeType<Value>Decoder for the value
descriptionstring?Help text
hintstring?Short note in parentheses
fallbackValueIfAbsent() => ValueValue when option is absent — throw to make it required
impliedValueIfNotInlined() => Value?Value when option is present but has no inline value (e.g. --output alone)
aliases{ longs?, shorts? }Additional names

optionRepeatable — collect multiple values

Collects every occurrence into an array.

ts
const files = optionRepeatable({
  long: "file",
  short: "f",
  type: typePath("FILE_PATH"),
  description: "Input file (may be repeated)",
});
// --file a.ts --file b.ts   →  ["a.ts", "b.ts"]
// (absent)                  →  []
ParameterTypeDescription
longstringLong option name
shortstring?Short option name
typeType<Value>Decoder applied to each occurrence
descriptionstring?Help text
hintstring?Short note in parentheses
aliases{ longs?, shorts? }Additional names

Aliases

All three option creators accept an aliases field for alternative names:

ts
optionFlag({
  long: "dry-run",
  aliases: { longs: ["dryrun"], shorts: ["n"] },
  description: "Print actions without executing them",
});
// --dry-run, --dryrun, and -n all work

CLI: Keep It Simple, Stupid. (KISS)