-
Notifications
You must be signed in to change notification settings - Fork 30k
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
readline: add getPrompt to get the current prompt #33675
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me. I think supporting this makes sense.
Can you please:
- Add a test (test/parallel/test-readline-interface.js is where I'd put it).
- Change the 8 other places in the code that use
._prompt
to.getPrompt()
(lib/internal/util.js, test-readline-interface and test-repl-options ideally).
Also cc @BridgeAR
Thank you for reviewing this so quickly! :) I will try to find the places where _prompt is used currently and change. |
Sorry, I somehow missed that, the test looks good to me, just the usages and I want Ruben's take on this since it affects the REPL :] |
@nodejs/readline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making my LGTM explicit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too bad that the prompt()
does not use a different name.
Anyone know anything about the tarball-failure? Does not seem connected to this change.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point we should runtime deprecate the public access to _prompt
but that can definitely be done later.
59b2c02
to
b17a0e6
Compare
b17a0e6
to
682f17f
Compare
Not sure how this is going, I did a rebase to keep it current. Is there a possibility to get this merged, I have seen no objections so far in the comments I've got. |
@mattiasrunge I think this was just missed between other PRs (sorry! This is our fault!). Any chance you could squash the commits into a single one so we can try landing this using the (automated) commit-queue rather than manually :]? |
Since there is a setPrompt() there should be a getPrompt(). There are use-cases where it is needed to know what the current prompt is. Adding a getPrompt() negates the need to store the set prompt externally or read the internal _prompt which would be bad practice. Co-authored-by: Colin Ihrig <cjihrig@gmail.com>
682f17f
to
f315b21
Compare
@benjamingr, now there should only be one squashed commit. |
This comment has been minimized.
This comment has been minimized.
Commit Queue failed- Loading data for nodejs/node/pull/33675 ✔ Done loading data for nodejs/node/pull/33675 ----------------------------------- PR info ------------------------------------ Title readline: add getPrompt to get the current prompt (#33675) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch mattiasrunge:readline-prompt-improve -> nodejs:master Labels author ready, readline Commits 1 - readline: add getPrompt to get the current prompt Committers 1 - Mattias Runge-Broberg PR-URL: https://github.com/nodejs/node/pull/33675 Reviewed-By: Colin Ihrig Reviewed-By: Anto Aravinth Reviewed-By: Benjamin Gruenbaum Reviewed-By: Ruben Bridgewater Reviewed-By: Michaël Zasso Reviewed-By: James M Snell ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/33675 Reviewed-By: Colin Ihrig Reviewed-By: Anto Aravinth Reviewed-By: Benjamin Gruenbaum Reviewed-By: Ruben Bridgewater Reviewed-By: Michaël Zasso Reviewed-By: James M Snell -------------------------------------------------------------------------------- ⚠ Commits were pushed since the last review: ⚠ - readline: add getPrompt to get the current prompt ✔ Last GitHub Actions successful ℹ Last Full PR CI on 2020-11-09T17:40:52Z: https://ci.nodejs.org/job/node-test-pull-request/34247/ - Querying data for job/node-test-pull-request/34247/ ✔ Build data downloaded ✔ Last Jenkins CI successful ℹ This PR was created on Sun, 31 May 2020 17:38:17 GMT ✔ Approvals: 6 ✔ - Colin Ihrig (@cjihrig) (TSC): https://github.com/nodejs/node/pull/33675#pullrequestreview-422280593 ✔ - Anto Aravinth (@antsmartian): https://github.com/nodejs/node/pull/33675#pullrequestreview-422315730 ✔ - Benjamin Gruenbaum (@benjamingr): https://github.com/nodejs/node/pull/33675#pullrequestreview-422469421 ✔ - Ruben Bridgewater (@BridgeAR) (TSC): https://github.com/nodejs/node/pull/33675#pullrequestreview-422533984 ✔ - Michaël Zasso (@targos) (TSC): https://github.com/nodejs/node/pull/33675#pullrequestreview-422547148 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/33675#pullrequestreview-422721331 -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncu Commit Queue action: https://github.com/nodejs/node/actions/runs/355594986 |
I'll resume CI and try landing with it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so goood, thank you 🎉
Landed in 3c38445...60a97c0 |
Since there is a setPrompt() there should be a getPrompt(). There are use-cases where it is needed to know what the current prompt is. Adding a getPrompt() negates the need to store the set prompt externally or read the internal _prompt which would be bad practice. Co-authored-by: Colin Ihrig <cjihrig@gmail.com> PR-URL: #33675 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Thank you for your contribution @mattiasrunge and congratulations on your first contribution 🎉 |
Woho! Thank you @benjamingr! |
Since there is a setPrompt() there should be a getPrompt(). There are use-cases where it is needed to know what the current prompt is. Adding a getPrompt() negates the need to store the set prompt externally or read the internal _prompt which would be bad practice. Co-authored-by: Colin Ihrig <cjihrig@gmail.com> PR-URL: #33675 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Notable changes: dns: * (SEMVER-MINOR) add a cancel() method to the promise Resolver (Szymon Marczak) #33099 events: * (SEMVER-MINOR) add max listener warning for EventTarget (James M Snell) #36001 http: * (SEMVER-MINOR) add support for abortsignal to http.request (Benjamin Gruenbaum) #36048 http2: * (SEMVER-MINOR) allow setting the local window size of a session (Yongsheng Zhang) #35978 lib: * (SEMVER-MINOR) add throws option to fs.f/l/statSync (Andrew Casey) #33716 path: * (SEMVER-MINOR) add `path/posix` and `path/win32` alias modules (ExE Boss) #34962 readline: * (SEMVER-MINOR) add getPrompt to get the current prompt (Mattias Runge-Broberg) #33675 src: * (SEMVER-MINOR) add loop idle time in diagnostic report (Gireesh Punathil) #35940 util: * (SEMVER-MINOR) add `util/types` alias module (ExE Boss) #34055 PR-URL: TODO
Notable changes: dns: * (SEMVER-MINOR) add a cancel() method to the promise Resolver (Szymon Marczak) #33099 events: * (SEMVER-MINOR) add max listener warning for EventTarget (James M Snell) #36001 http: * (SEMVER-MINOR) add support for abortsignal to http.request (Benjamin Gruenbaum) #36048 http2: * (SEMVER-MINOR) allow setting the local window size of a session (Yongsheng Zhang) #35978 lib: * (SEMVER-MINOR) add throws option to fs.f/l/statSync (Andrew Casey) #33716 path: * (SEMVER-MINOR) add `path/posix` and `path/win32` alias modules (ExE Boss) #34962 readline: * (SEMVER-MINOR) add getPrompt to get the current prompt (Mattias Runge-Broberg) #33675 src: * (SEMVER-MINOR) add loop idle time in diagnostic report (Gireesh Punathil) #35940 util: * (SEMVER-MINOR) add `util/types` alias module (ExE Boss) #34055 PR-URL: TODO
Notable changes: dns: * (SEMVER-MINOR) add a cancel() method to the promise Resolver (Szymon Marczak) #33099 events: * (SEMVER-MINOR) add max listener warning for EventTarget (James M Snell) #36001 http: * (SEMVER-MINOR) add support for abortsignal to http.request (Benjamin Gruenbaum) #36048 http2: * (SEMVER-MINOR) allow setting the local window size of a session (Yongsheng Zhang) #35978 lib: * (SEMVER-MINOR) add throws option to fs.f/l/statSync (Andrew Casey) #33716 path: * (SEMVER-MINOR) add `path/posix` and `path/win32` alias modules (ExE Boss) #34962 readline: * (SEMVER-MINOR) add getPrompt to get the current prompt (Mattias Runge-Broberg) #33675 src: * (SEMVER-MINOR) add loop idle time in diagnostic report (Gireesh Punathil) #35940 util: * (SEMVER-MINOR) add `util/types` alias module (ExE Boss) #34055 PR-URL: #36232
Notable changes: dns: * (SEMVER-MINOR) add a cancel() method to the promise Resolver (Szymon Marczak) #33099 events: * (SEMVER-MINOR) add max listener warning for EventTarget (James M Snell) #36001 http: * (SEMVER-MINOR) add support for abortsignal to http.request (Benjamin Gruenbaum) #36048 http2: * (SEMVER-MINOR) allow setting the local window size of a session (Yongsheng Zhang) #35978 lib: * (SEMVER-MINOR) add throws option to fs.f/l/statSync (Andrew Casey) #33716 path: * (SEMVER-MINOR) add `path/posix` and `path/win32` alias modules (ExE Boss) #34962 readline: * (SEMVER-MINOR) add getPrompt to get the current prompt (Mattias Runge-Broberg) #33675 src: * (SEMVER-MINOR) add loop idle time in diagnostic report (Gireesh Punathil) #35940 util: * (SEMVER-MINOR) add `util/types` alias module (ExE Boss) #34055 PR-URL: #36232
Since there is a setPrompt() there should be a getPrompt(). There are use-cases where it is needed to know what the current prompt is. Adding a getPrompt() negates the need to store the set prompt externally or read the internal _prompt which would be bad practice. Co-authored-by: Colin Ihrig <cjihrig@gmail.com> PR-URL: #33675 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Since there is a setPrompt() there should be a getPrompt().
There are use-cases where it is needed to know what the
current prompt is. Adding a getPrompt() negates the need
to store the set prompt externally or read the internal
_prompt which would be bad practice.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes