Comments (9)
Done! Minimist in v2.
from zx.
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.
Another argument parsing library to consider (I personally prefer it over minimist): https://github.com/vercel/arg
from zx.
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.
My thoughts exactly
from zx.
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.
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.
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.
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)
- feat req: provide `signal` opt
- Setting stdio/err to inherit throws error HOT 1
- Typo in 8.0 release description HOT 1
- Feature request: automatically add a newline after commands that don't end their output with one HOT 4
- The type for `glob` is `any` after 8.0.0 HOT 5
- Port listening doesn't stop when using `CTRL+C` HOT 11
- Feature request: add `usePwsh` helper for PowerShell 7+ HOT 3
- Why zx instead of Python ? HOT 2
- Markdown script didn't work for CRLF file
- Is Node.js 12.17.0 supported for zx as a package ? HOT 7
- Single file executable?
- Docs: Typo in setup docs
- fetch's document link is wrong HOT 4
- bun compatibility: get rid of async_hooks.createHook call HOT 3
- cannot concatenate strings with ${} HOT 4
- Understanding `zx` roadmap and idea 🙏 HOT 6
- YAML.parseAllDocuments is no longer accessible HOT 8
- Provide better out of the box TypeScript support HOT 2
- Could not resolve "zx/globals.cjs" HOT 4
- Since 8.1.4 YAML.parseAllDocuments is not allowed from zx HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zx.