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

parseArgs Type Definition #47487

Open
marcobarrios-fi opened this issue Apr 8, 2023 · 5 comments
Open

parseArgs Type Definition #47487

marcobarrios-fi opened this issue Apr 8, 2023 · 5 comments
Labels
util Issues and PRs related to the built-in util module.

Comments

@marcobarrios-fi
Copy link

marcobarrios-fi commented Apr 8, 2023

Instead of having a type property with either a "string" or "boolean" value, I believe it would be more intuitive to have a boolean property with either true or false value, with the default value being false.

options: {
  verbose: {
    short: "v",
    boolean: true
  }
}

Furthermore, I would prefer the options to be an array of objects, as this would make it easier work with them.

options: [
  {
    long: "output",
    short: "o",
    required: true
  },
  {
    long: "verbose",
    short: "v",
    boolean: true
  }
}

Thank you for including the parseArgs feature in Node!

@benjamingr
Copy link
Member

cc @bcoe @RaisinTen @aduh95 (pinging Ben who added it and some people who reviewed that since I'm not sure what team to ping)

@VoltrexKeyva VoltrexKeyva added the util Issues and PRs related to the built-in util module. label Apr 9, 2023
@shadowspawn
Copy link
Member

shadowspawn commented Apr 9, 2023

Instead of having a type property with either a "string" or "boolean" value, I believe it would be more intuitive to have a boolean property with either true or false value, with the default value being false.

This was deliberate in case there was expansion of types in the future or by third parties. The original design had a withValue array and the current naming was first discussed in refactor: pkgjs/parseargs#63 (comment)

@shadowspawn
Copy link
Member

shadowspawn commented Apr 9, 2023

Furthermore, I would prefer the options to be an array of objects, as this would make it easier work with them.

I think implicitly we were thinking of a key/value lookup of the options properties, but an array could work too. I think the difference is probably not compelling enough to change, also with parseArgs moving to stable in #46640

Proposal for refactor leading to current configuration:
pkgjs/parseargs#45

Edit: Also I don't know if it would be possible to do the strong typing of the parse results in TypeScript if the options configuration was a plain array.

@shadowspawn
Copy link
Member

(Two good questions @marcobarriosfi )

@benjamingr
Copy link
Member

(The TS bit is possible to type though I actually personally like the current API better)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
util Issues and PRs related to the built-in util module.
Projects
None yet
Development

No branches or pull requests

4 participants