Optique: Type-safe combinatorial CLI parser for TypeScript

Type-safe combinatorial CLI parser for TypeScript inspired by Haskell's
optparse-applicative and TypeScript's Zod. Build composable parsers for
command-line interfaces with full type safety, automatic type inference, and
built-in shell completion support for Bash, zsh, fish, PowerShell, and Nushell.
Optique also supports config files. Use @optique/man to generate man pages
from parser definitions. The @optique/man/markdown renderer combines command
pages into a linked Markdown reference.
[!NOTE]
Optique is a parsing library that focuses on extracting and validating
command-line arguments. It doesn't dictate your application's structure,
handle command execution, or provide scaffolding—it simply transforms
command-line input into well-typed data structures.
Why Optique
- Composable by default: Build small parser pieces and combine them into
larger CLIs without losing readability or types.
- Types that model real CLI rules: Optional flags, mutually exclusive
branches, and dependent options are reflected directly in inferred types.
- One parser, many outputs: Derive help text, shell completions, and
(with @optique/man) man pages from the same parser definition.
- Practical integrations: Extend parsers with config files, environment
variables, OS credential stores, schema validators, interactive prompts, and
git-aware parsing.
- Command discovery: Split larger command trees into files with
@optique/discover while keeping parser-driven help and completion.
- Cross-runtime consistency: Use the same parser model in Deno, Node.js,
and Bun.
Features
- Parser combinators:
object(), or(), merge(), optional(),
multiple(), map(), conditional(), passThrough(), and more
for composable CLI parsing
- Full type safety: Automatic TypeScript type inference for all parser
compositions with compile-time validation
- Rich value parsers: Built-in parsers for strings, numbers, URLs, locales,
UUIDs, networking types (
port(), ipv4(), hostname(), email(), etc.),
Temporal types (via @optique/temporal), Standard Schema validators (via
@optique/standard-schema), Zod schemas (via @optique/zod), and Valibot
schemas (via @optique/valibot)
- Config file support: Load config from files with Standard Schema
validation (via @optique/config), supporting Zod, Valibot, ArkType, and
more
- Environment variable support: Bind options to environment variables
with type-safe parsing and fallback behavior (via @optique/env)
- OS credential-store support: Fill missing password options from the OS
credential store with async fallback behavior (via @optique/keyring)
- Derived defaults: Compute default values from the first-pass parse result
without lowering CLI argument priority (via @optique/derived-defaults)
- Interactive prompts: Prompt users for missing values via Inquirer.js or
Clack with parser-integrated fallback flows (via @optique/inquirer and
@optique/clack)
- Inter-option dependencies: Options whose valid values depend on other
options, with dynamic validation and context-aware shell completion
- Async parser support: Type-safe sync/async mode distinction for parsers
that validate against external sources like git refs or remote APIs
- Man page generation: Generate Unix man pages directly from parser
definitions (via @optique/man), keeping documentation always in sync
- Command discovery: Discover command modules from a directory and dispatch
to type-checked handlers (via @optique/discover)