Coder Social home page Coder Social logo

Comments (9)

antonmedv avatar antonmedv commented on May 2, 2024 6

Done! Minimist in v2.

from zx.

mainrs avatar mainrs commented on May 2, 2024 5

We could consider detecting numbers, and parsing those, but that already makes it tricky.

No need for that. If a script uses the API it already knows if an argument should be a number. Stuff like that should be handled by the script writer. A simple string/boolean case should be enough.

Maybe instead of going for popularity of a parsing package one could argue that the smallest one with the fastest loading time might be the best to choose. Just another way to look at the discussion.

from zx.

rauschma avatar rauschma commented on May 2, 2024 4

Another argument parsing library to consider (I personally prefer it over minimist): https://github.com/vercel/arg

from zx.

antonmedv avatar antonmedv commented on May 2, 2024 3

The problem with it what there are too many alternatives, and everybody wants a different one.

  • yargs ~57M/week
  • minimist ~41M/week
  • arg ~7M/week
  • meow ~15M/week
  • countless others ~100M/week

from zx.

smeijer avatar smeijer commented on May 2, 2024 1

My thoughts exactly

from zx.

brandonpittman avatar brandonpittman commented on May 2, 2024 1

Another argument parsing library to consider (I personally prefer it over minimist): vercel/arg

arg is definitely the closest to the metal and inline with zx's vision.

from zx.

smeijer avatar smeijer commented on May 2, 2024

I was thinking about limiting the integration to expose the arguments under global.argv, in the most basic form. Arguments would be exposed as strings when a value was provided (zx script.js --username smeijer), or booleans when not (zx script.js -xyz). We could consider detecting numbers, and parsing those, but that already makes it tricky.

Whenever the user needs more (like support for --help, or type coercion), they can install their library of choice.

For this project, I think the best option would be the simplest/smallest library.

from zx.

ethanmick avatar ethanmick commented on May 2, 2024

Using zx for the first time and really enjoying it. This use case just came up as I wanted to add a little more configuration for other users who may use it. A simple way to get flagged arguments would be very nice. Maybe some inspiration can be taken from the Go flag package; simple, and if people still need more power than can install another one.

from zx.

smeijer avatar smeijer commented on May 2, 2024

The difference I see between minimist and arg, is that minimist doesn't require any options/setup to be useful. While arg needs initialization.

As arg requires setup, one might as well just add the import statement as well.

from zx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.