Lemmini.fi
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
洪 民憙 (Hong Minhee)@lemmy.ml to TypeScript@programming.devEnglish · 8 days ago

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

hackers.pub

external-link
message-square
0
link
fedilink
  • cross-posted to:
  • [email protected]
  • [email protected]
  • [email protected]
4
external-link

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

hackers.pub

洪 民憙 (Hong Minhee)@lemmy.ml to TypeScript@programming.devEnglish · 8 days ago
message-square
0
link
fedilink
  • cross-posted to:
  • [email protected]
  • [email protected]
  • [email protected]
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.
alert-triangle
You must log in or # to comment.

TypeScript@programming.dev

typescript@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: [email protected]
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 1 user / day
  • 1 user / week
  • 9 users / month
  • 56 users / 6 months
  • 1 local subscriber
  • 1.03K subscribers
  • 58 Posts
  • 3 Comments
  • Modlog
  • mods:
  • snowe@programming.dev
  • Ategon@programming.dev
  • BE: 0.19.12
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org