Optique: A TypeScript library that eliminates CLI validation code through parser combinators and type inference
By
dahlia
A baker's-dozen of insight crammed into one ring.
Summary
The article introduces Optique, a new TypeScript library for CLI argument parsing that uses parser combinators and type inference to eliminate the need for manual validation code. The author was motivated by observing repetitive validation patterns (dependent options, mutually exclusive options, defaults) across countless CLI tools. Optique allows developers to describe CLI configurations declaratively, with TypeScript automatically inferring types and constraints at compile time, catching bugs before runtime. The author shares their experience of deleting large validation code blocks and simplifying refactoring, positioning Optique as a more robust and maintainable alternative to traditional CLI parsing approaches.
Key quotes
· 3 pulledI have this bad habit. When something annoys me enough times, I end up building a library for it.
every CLI tool has the same ugly validation code tucked away somewhere
Optique leverages parser combinators and TypeScript's type inference to ensure that CLI arguments are parsed directly into valid configurations, eliminating the need for manual validation
You might also wanna read
Erlang Ecosystem Foundation Launches Central Company Registry
The Erlang Ecosystem Foundation has launched a new canonical company registry at registry.erlef.org. The registry aims to serve members, spo
aislop: Open-source CLI tool detects low-quality code patterns left by AI coding agents
aislop is an open-source CLI tool (MIT-licensed) that detects low-quality patterns left behind by AI coding agents like Claude Code, Cursor,
OpenStatus: Open-Source Status Page and Uptime Monitoring Platform
OpenStatus is an open-source status page and uptime monitoring platform designed for developers to showcase their service reliability. It pr
Jujutsu (jj): A Git-Compatible Version Control System Focused on Simplicity and Power
Jujutsu (jj) is a Git-compatible version control system designed to be both simple and powerful. It abstracts the user interface and version
xlide_vscode: Edit Excel VBA Code Directly in VS Code with Full Read/Write and AI Integration
This article presents xlide_vscode, an open-source VS Code extension that enables direct editing of Excel VBA code within Visual Studio Code
tldx: Open-source CLI tool for bulk domain availability checking via RDAP
tldx is an open-source, blazing-fast CLI tool written in Go that bulk-checks domain availability via RDAP. It allows users to generate and c
