lemmy.amxl.com
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
洪 民憙 (Hong Minhee)@lemmy.ml to General Programming Discussion@lemmy.mlEnglish · 12 days ago

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

hackers.pub

external-link
message-square
0
fedilink
  • cross-posted to:
  • programming@programming.dev
13
external-link

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

hackers.pub

洪 民憙 (Hong Minhee)@lemmy.ml to General Programming Discussion@lemmy.mlEnglish · 12 days ago
message-square
0
fedilink
  • cross-posted to:
  • programming@programming.dev
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 register to comment.

General Programming Discussion@lemmy.ml

programming@lemmy.ml

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: !programming@lemmy.ml

A general programming discussion community.

Rules:

  1. Be civil.
  2. Please start discussions that spark conversation

Other communities

  • !python@lemmy.ml
  • !powershell@lemmy.ml
  • !julia@lemmy.ml
  • !iosprogramming@lemmy.ml

Systems

  • !rust@lemmy.ml
  • !cpp@lemmy.ml
  • !c_programming@lemmy.ml

Functional Programming

  • !haskell@lemmy.ml
  • !fpcomplete@lemmy.ml

Also related

  • !opensource@lemmy.ml
Visibility: Public
globe

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

  • 2 users / day
  • 8 users / week
  • 46 users / month
  • 286 users / 6 months
  • 2 local subscribers
  • 8.97K subscribers
  • 313 Posts
  • 749 Comments
  • Modlog
  • mods:
  • Evan@lemmy.ml
  • Restioson@lemmy.ml
  • BE: 0.19.9
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org