Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util: parseArgs instead of string and boolean should handle all primitive data types #44484

Closed
ErickWendel opened this issue Sep 1, 2022 · 3 comments
Labels
feature request Issues that request new features to be added to Node.js.

Comments

@ErickWendel
Copy link
Member

ErickWendel commented Sep 1, 2022

What is the problem this feature will solve?

In today's @nodejs/tooling WG meeting, we're discussing the parseArgs that the config supports only either boolean or string for parsing args.

nodejs/tooling#155

What is the feature you are proposing to solve the problem?

I'd like to open for discussion on whether we should support other primitive types such as numbers and complex types such as Streams.

There're some concerns about it but I think it will be worth it to hear what other people think about it

What alternatives have you considered?

No response

@ErickWendel ErickWendel added the feature request Issues that request new features to be added to Node.js. label Sep 1, 2022
@shadowspawn
Copy link
Member

Just regarding numbers.

I assume when you say support for "numbers" you are thinking of it as as explicit type specified by the author, rather than auto-detection? (Both minimist and yargs have reported issues about automatic detection going wrong, some false positives of ids, some due to overflow.)

Negative numbers clash with the ability to use a digit as an option, like ls -1. This means some compromises are needed to support negative numbers. There is some prior discussion in a PR that proposed one form of negative number support in pkgjs/parseargs#62

I'm comfortable with parseArgs staying simple and not supporting type conversions. (But I am also very comfortable reaching for a library when I need more!)

@mcollina
Copy link
Member

mcollina commented Sep 4, 2022

I don't think we should support streams or any other complex types. That's best left to userland.

@Mouvedia
Copy link

Mouvedia commented Oct 3, 2024

type: "number" would have been a welcomed addition.
meow supports it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js.
Projects
None yet
Development

No branches or pull requests

4 participants