Stop writing CLI validation. Parse it right the first time.

洪 民憙 (Hong Minhee) @hongminhee@hackers.pub

This post introduces Optique, a new library created to address the pervasive problem of repetitive and often messy validation code in CLI tools. The author was motivated by the observation that nearly every CLI tool reinvents the wheel with similar validation patterns for dependent options, mutually exclusive options, and environment-specific requirements. 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. By describing the desired CLI configuration with Optique, TypeScript automatically infers the types and constraints, catching potential bugs at compile time. The author shares their experience of deleting large chunks of validation code and simplifying refactoring tasks. Optique aims to provide a more robust and maintainable approach to CLI argument parsing, potentially saving developers from writing the same validation logic repeatedly.

Read more →
19
3
1

❤️

19 people reacted.

지금까지 다루어 봤던 언어는 아래와 같습니다. MSX Basic Z80 Assembly Pascal GW-Basic C Macromedia Director Visual Basic PHP Flash Actionscript C++ Javascript

그리고 지금은, 하스켈을 비즈니스에 쓰려고 몇 년간 노력하고 있습니다. 지금 상태는, 하스켈 자체를 연구하는 게 아니라, 하스켈 (혹은 함수형 언어) 이해가 어려운 이유를 연구하는 아마추어 연구가쯤 되어버렸습니다. 하스켈 주제로 블로그를 운영 중이지만, 아직은 하스켈 프로그래머라고 자신 있게 말하진 못하고 있습니다. 가끔 이해에 도움이 될만한 측면이 보이면, 가볍게 아이디어를 여러 SNS에 올려보곤 하는데, 그다지 프로그래머에게 쓸모 있는 내용이 포함되진 않는 것 같습니다.

개발곰의 해커스펍 계정 - 개발 외적인 내용은 yuri.garden에서 찾아주세요.

프론트엔드를 기반으로 JS/TS 전반에 관심이 많습니다. 요즘에는 홈서버 구축을 어떻게 할지 관심을 두고 있습니다.

Haze Lee but also known as Kihan Park

  • 💻 Make stuff with Computer
  • 💉 Living with Migraine more than 10y, Migraine Advocate [Headache Place]
  • 💬 🇰🇷, Also 🇯🇵 & 🇬🇧🇺🇸

Functional programming, TypeScript, tooling.
 He/him. Views and opinions my own and do not reflect those of my employer.

I usually only follow folks with pronouns in bio.

무엇이든 만드는 것 좋아합니다

math. programming. fancy types. haskell.
6d03.info

A nonbinary fox working on DOM in Gecko. Not a guy in any form, not even in "you guys" form

Mid-40s techie living in , , UK. Mostly low-level software with bits of and stuff, , . Discoverer of the "Snark" in . Currently working on memory subsystems for packet matching and filtering in high-speed networking equipment.

Player of , under the name "Wrongfellow". I've used this name elsewhere, too.

and lover. Drinker of and . Occasional and volunteer.

私はソウルに住んでいる30代後半のオープンソースソフトウェアエンジニアで、自由・オープンソースソフトウェアとフェディバースの熱烈な支持者です。

私はTypeScript用のActivityPubサーバーフレームワークである「@fedifyFedify: ActivityPub server framework」と、1人用フェディバースのマイクロブログである 「@holloHollo :hollo:」の作成者でもあります。

このアカウントは主に日本語で話します。まだ日本語が下手なので、ご理解ください。メインアカウントは「@hongminhee洪 民憙 (Hong Minhee)」(主に英語)です。

主にFedifyとHolloについて話します。韓国と日本の文化的・言語的な共通点と相違点をよく話します。日本語はまだ流暢ではありません。