Orbi Camp
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
洪 民憙 (Hong Minhee)@lemmy.ml to Programming@programming.devEnglish · 10 days ago

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

hackers.pub

external-link
message-square
20
fedilink
109
external-link

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

hackers.pub

洪 民憙 (Hong Minhee)@lemmy.ml to Programming@programming.devEnglish · 10 days ago
message-square
20
fedilink
  • Onno (VK6FLAB)@lemmy.radio
    link
    fedilink
    arrow-up
    2
    ·
    9 days ago

    I’ve used the node.js version of argparse, which as I understand it, is a clone of the python implementation and I’ve not seen how to do mutually exclusive flags. Mind you, at the time I didn’t need them, so it wasn’t an issue, but I don’t recall seeing any way to do it either.

    Did I miss something?

    • azertyfun@sh.itjust.works
      link
      fedilink
      arrow-up
      3
      ·
      9 days ago

      https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.add_mutually_exclusive_group

      However I’ve never had to use that feature. Like I said it can make sense in specific contexts but it is a pretty strong indicator that you have built in a CLI antipattern or too much complexity.

Programming@programming.dev

programming@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]

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you’re posting long videos try to add in some form of tldr for those who don’t want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



Visibility: Public
globe

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

  • 84 users / day
  • 572 users / week
  • 2.63K users / month
  • 7.95K users / 6 months
  • 1 local subscriber
  • 22.7K subscribers
  • 819 Posts
  • 9.21K Comments
  • Modlog
  • mods:
  • snowe@programming.dev
  • Ategon@programming.dev
  • MaungaHikoi@lemmy.nz
  • UlrikHD@programming.dev
  • BE: 0.19.8
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org