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: add parseArgs module #42675
util: add parseArgs module #42675
Conversation
Review requested: |
I would recommend this to be exposed as |
It definitely should not be exposed only under the prefix, for a ton of reasons (but that’s being discussed elsewhere) |
@mcollina done, opted for |
I am -1 on it being exposed only under the I am, however, +1 on this landing assuming we can come to consensus on it. |
My assumption thus far was that |
Left a few comments.
Regarding the node:
scheme - there is a vote on this in nodejs/TSC#1206, which is expected to be completed Monday (so a decision can be made in time for Node 18). I think the outcome there should dictate how this module is exposed.
@cjihrig @mcollina @bnb, can we agree that we will have the functionality available in |
I'm totally ok for it to stay inside |
@cjihrig @mcollina @Trott how would folks feel about this feature experimental in docs only? with strong warnings in the documentation that this is a work in progress? On one hand, a runtime experimental warning makes it difficult to create real-world command line applications, as they'll have noisy output. On the other hand, users might not realize it's experimental and get frustrated if the API breaks. |
I'm ok in being doc-only experimental. |
I'd punt that to @nodejs/tsc and @nodejs/releasers. I'm personally fine with it, but I also wouldn't want that to sneak by anyone. I'm not sure if this is actually feasible, but maybe we can split the difference and have a warning be emitted (so if anything is listening for warnings, it picks it up) but ignored by the default "print the warning to the console" listener. |
I don't mind due to the nature of this API. |
@nodejs/tsc two questions I would love feedback on from the TSC:
|
I think it's okay to expose this as a part of the util module. It probably doesn't require a completely new module of its own because it's just a single function.
I'm okay with it. |
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
Fixes pkgjs/parseargs#109 |
I think this is ready to land, but it could use one more approval or re-approval since changes have been made since the last approval (and the commit queue won't merge something in that case). I'll rubber-stamp re-approve if no one wants to give it a proper review, but hopefully someone would like to look at it one more time? |
Landed in 4a3ba87 |
Adds util.parseArgs helper for higher level command-line argument parsing. PR-URL: #42675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruy Adorno <ruyadorno@github.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Joe Sepi <sepi@joesepi.com> Reviewed-By: Ian Sutherland <ian@iansutherland.ca>
Notable changes: * deps: update undici to 5.3.0 (Node.js GitHub Bot) #43197 * (SEMVER-MINOR) util: add parseArgs module (Benjamin Coe) #42675 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) #41397 * deps: upgrade npm to 8.11.0 (npm team) #43210 * deps: patch V8 to 10.2.154.4 (Michaël Zasso) #43067 * (SEMVER-MINOR) deps: update V8 to 10.2.154.2 (Michaël Zasso) #42740 * (SEMVER-MINOR) fs: make params in writing methods optional (LiviaMedeiros) #42601 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) #41397 * (SEMVER-MINOR) net: add ability to reset a tcp socket (pupilTong) #43112 PR-URL: TBD
Notable changes: * deps: update undici to 5.3.0 (Node.js GitHub Bot) #43197 * (SEMVER-MINOR) util: add parseArgs module (Benjamin Coe) #42675 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) #41397 * deps: upgrade npm to 8.11.0 (npm team) #43210 * deps: patch V8 to 10.2.154.4 (Michaël Zasso) #43067 * (SEMVER-MINOR) deps: update V8 to 10.2.154.2 (Michaël Zasso) #42740 * (SEMVER-MINOR) fs: make params in writing methods optional (LiviaMedeiros) #42601 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) #41397 * (SEMVER-MINOR) net: add ability to reset a tcp socket (pupilTong) #43112 PR-URL: #43266
Notable changes: * deps: update undici to 5.3.0 (Node.js GitHub Bot) #43197 * (SEMVER-MINOR) util: add parseArgs module (Benjamin Coe) #42675 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) #41397 * deps: upgrade npm to 8.11.0 (npm team) #43210 * deps: patch V8 to 10.2.154.4 (Michaël Zasso) #43067 * (SEMVER-MINOR) deps: update V8 to 10.2.154.2 (Michaël Zasso) #42740 * (SEMVER-MINOR) fs: make params in writing methods optional (LiviaMedeiros) #42601 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) #41397 * (SEMVER-MINOR) net: add ability to reset a tcp socket (pupilTong) #43112 * (SEMVER-MINOR) Revert "build: make x86 Windows support temporarily experimental" (Michaël Zasso) [#42740](#42740) * This means 32-bit Windows binaries are back with this release. PR-URL: #43266
Notable changes: * deps: update undici to 5.3.0 (Node.js GitHub Bot) #43197 * (SEMVER-MINOR) util: add parseArgs module (Benjamin Coe) #42675 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) #41397 * deps: upgrade npm to 8.11.0 (npm team) #43210 * deps: patch V8 to 10.2.154.4 (Michaël Zasso) #43067 * (SEMVER-MINOR) deps: update V8 to 10.2.154.2 (Michaël Zasso) #42740 * (SEMVER-MINOR) fs: make params in writing methods optional (LiviaMedeiros) #42601 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) #41397 * (SEMVER-MINOR) net: add ability to reset a tcp socket (pupilTong) #43112 * (SEMVER-MINOR) Revert "build: make x86 Windows support temporarily experimental" (Michaël Zasso) [#42740](#42740) * This means 32-bit Windows binaries are back with this release. PR-URL: #43266
Notable changes: * deps: update undici to 5.4.0 (Node.js GitHub Bot) #43262 * (SEMVER-MINOR) util: add parseArgs module (Benjamin Coe) #42675 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) #41397 * deps: upgrade npm to 8.11.0 (npm team) #43210 * deps: patch V8 to 10.2.154.4 (Michaël Zasso) #43067 * (SEMVER-MINOR) deps: update V8 to 10.2.154.2 (Michaël Zasso) #42740 * (SEMVER-MINOR) fs: make params in writing methods optional (LiviaMedeiros) #42601 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) #41397 * (SEMVER-MINOR) net: add ability to reset a tcp socket (pupilTong) #43112 * (SEMVER-MINOR) Revert "build: make x86 Windows support temporarily experimental" (Michaël Zasso) [#42740](#42740) * This means 32-bit Windows binaries are back with this release. PR-URL: #43266
Notable changes: * deps: update undici to 5.4.0 (Node.js GitHub Bot) #43262 * (SEMVER-MINOR) util: add parseArgs module (Benjamin Coe) #42675 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) #41397 * deps: upgrade npm to 8.11.0 (npm team) #43210 * deps: patch V8 to 10.2.154.4 (Michaël Zasso) #43067 * (SEMVER-MINOR) deps: update V8 to 10.2.154.2 (Michaël Zasso) #42740 * (SEMVER-MINOR) fs: make params in writing methods optional (LiviaMedeiros) #42601 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) #41397 * (SEMVER-MINOR) net: add ability to reset a tcp socket (pupilTong) #43112 * (SEMVER-MINOR) Revert "build: make x86 Windows support temporarily experimental" (Michaël Zasso) [#42740](#42740) * This means 32-bit Windows binaries are back with this release. PR-URL: #43266
Notable changes: * deps: update undici to 5.4.0 (Node.js GitHub Bot) nodejs#43262 * (SEMVER-MINOR) util: add parseArgs module (Benjamin Coe) nodejs#42675 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) nodejs#41397 * deps: upgrade npm to 8.11.0 (npm team) nodejs#43210 * deps: patch V8 to 10.2.154.4 (Michaël Zasso) nodejs#43067 * (SEMVER-MINOR) deps: update V8 to 10.2.154.2 (Michaël Zasso) nodejs#42740 * (SEMVER-MINOR) fs: make params in writing methods optional (LiviaMedeiros) nodejs#42601 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) nodejs#41397 * (SEMVER-MINOR) net: add ability to reset a tcp socket (pupilTong) nodejs#43112 * (SEMVER-MINOR) Revert "build: make x86 Windows support temporarily experimental" (Michaël Zasso) [nodejs#42740](nodejs#42740) * This means 32-bit Windows binaries are back with this release. PR-URL: nodejs#43266
Adds util.parseArgs helper for higher level command-line argument parsing. PR-URL: nodejs/node#42675 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruy Adorno <ruyadorno@github.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Joe Sepi <sepi@joesepi.com> Reviewed-By: Ian Sutherland <ian@iansutherland.ca>
Notable changes: * deps: update undici to 5.4.0 (Node.js GitHub Bot) nodejs/node#43262 * (SEMVER-MINOR) util: add parseArgs module (Benjamin Coe) nodejs/node#42675 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) nodejs/node#41397 * deps: upgrade npm to 8.11.0 (npm team) nodejs/node#43210 * deps: patch V8 to 10.2.154.4 (Michaël Zasso) nodejs/node#43067 * (SEMVER-MINOR) deps: update V8 to 10.2.154.2 (Michaël Zasso) nodejs/node#42740 * (SEMVER-MINOR) fs: make params in writing methods optional (LiviaMedeiros) nodejs/node#42601 * (SEMVER-MINOR) http: add uniqueHeaders option to request and createServer (Paolo Insogna) nodejs/node#41397 * (SEMVER-MINOR) net: add ability to reset a tcp socket (pupilTong) nodejs/node#43112 * (SEMVER-MINOR) Revert "build: make x86 Windows support temporarily experimental" (Michaël Zasso) [#42740](nodejs/node#42740) * This means 32-bit Windows binaries are back with this release. PR-URL: nodejs/node#43266
Adds util.parseArgs helper for higher level command-line argument parsing.
Background
There has been an ongoing effort in pkgjs/parseargs to define a command-line argument parsing API for Node.js core.
The effort has taken several years to get to this point, with many amazing contributors across a variety of companies and projects: IBM, Microsoft, Google, Shopify, npm, nvm, commander, yargs, just to name a few.
Where parseArgs is at
@shadowspawn, who's been most recently pushing a lot of the work on
parseArgs
forward, indicates in pkgjs/parseargs/issues/87 that "we're close to having a decent MVP."I agree, and thought it would be worth having a candidate PR open on Node.js to get additional feedback.
This is a controversial topic, be kind
There's a lot of nuance and opinion, as to what constitutes a "decent MVP" for a command-line argument parser. Please be respectful of opinions you might not agree with😊
Before leaving feedback on this thread, I suggest reading past issues on
parseArgs
. Perhaps there's already been a discussion that touches on your feedback (or there's an ongoing discussion).Similarly, if themes of discussion jump out in this PR, let's move them to an issue in
parseArgs
(this should help keep this PR less confusing).ToDo
CC: @ljharb, @bakkot, @iansu, @darcyclarke, @ruyadorno, @shadowspawn, @nodejs/tooling, @Trott (who I believe asked after this), @aaronccasanova.