Lemmy
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
洪 民憙 (Hong Minhee) to General Programming DiscussionEnglish · 1 year ago

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

hackers.pub

external-link
message-square
0
link
fedilink
  • cross-posted to:
  • lobsters@lemmy.bestiver.se
  • typescript@programming.dev
  • typescript
  • programming@programming.dev
15
external-link

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

hackers.pub

洪 民憙 (Hong Minhee) to General Programming DiscussionEnglish · 1 year ago
message-square
0
link
fedilink
  • cross-posted to:
  • lobsters@lemmy.bestiver.se
  • typescript@programming.dev
  • typescript
  • 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

programming

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.

  • 3 users / day
  • 69 users / week
  • 145 users / month
  • 629 users / 6 months
  • 4.35K local subscribers
  • 10K subscribers
  • 1.7K Posts
  • 2.51K Comments
  • Modlog
  • mods:
  • Evan
  • Restioson
  • BE: 0.19.20
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org