The Wayback Machine - https://web.archive.org/web/20220423151817/https://github.com/nodejs/node/pull/33675
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

readline: add getPrompt to get the current prompt #33675

Closed

Conversation

Copy link
Contributor

@mattiasrunge mattiasrunge commented May 31, 2020

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), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
@nodejs-github-bot nodejs-github-bot added the readline label May 31, 2020
doc/api/readline.md Outdated Show resolved Hide resolved
doc/api/readline.md Show resolved Hide resolved
Copy link
Member

@benjamingr benjamingr left a comment

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

@mattiasrunge
Copy link
Contributor Author

@mattiasrunge mattiasrunge commented May 31, 2020

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! :)
Not sure exactly what you mean by adding a test. I have already added a test in the file you suggested. Do you want me to test something more?

I will try to find the places where _prompt is used currently and change.

@benjamingr
Copy link
Member

@benjamingr benjamingr commented May 31, 2020

I have already added a test in the file you suggested.

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 :]

@benjamingr
Copy link
Member

@benjamingr benjamingr commented Jun 1, 2020

doc/api/readline.md Outdated Show resolved Hide resolved
Copy link
Member

@benjamingr benjamingr left a comment

Making my LGTM explicit

Copy link
Member

@BridgeAR BridgeAR left a comment

Too bad that the prompt() does not use a different name.

@mattiasrunge
Copy link
Contributor Author

@mattiasrunge mattiasrunge commented Jun 2, 2020

Anyone know anything about the tarball-failure? Does not seem connected to this change.

2020-06-01T21:08:57.0714361Z ##[section]Starting: Request a runner to run this job
2020-06-01T21:08:57.4754213Z Can't find any online and idle self-hosted runner in current repository that matches the required labels: 'macos-latest'
2020-06-01T21:08:57.4754260Z Can't find any online and idle self-hosted runner in current repository's account/organization that matches the required labels: 'macos-latest'
2020-06-01T21:08:57.4754294Z Found online and idle hosted runner in current repository's account/organization that matches the required labels: 'macos-latest'
2020-06-01T21:08:57.6616451Z ##[section]Finishing: Request a runner to run this job
Copy link
Member

@jasnell jasnell left a comment

At some point we should runtime deprecate the public access to _prompt but that can definitely be done later.

@mattiasrunge
Copy link
Contributor Author

@mattiasrunge mattiasrunge commented Oct 14, 2020

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.

@benjamingr
Copy link
Member

@benjamingr benjamingr commented Oct 15, 2020

@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>
@mattiasrunge
Copy link
Contributor Author

@mattiasrunge mattiasrunge commented Oct 19, 2020

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 :]?

@benjamingr, now there should only be one squashed commit.

@aduh95 aduh95 added author ready request-ci labels Nov 8, 2020
@github-actions github-actions bot removed the request-ci label Nov 8, 2020
@nodejs-github-bot

This comment has been minimized.

@aduh95 aduh95 added the commit-queue label Nov 10, 2020
@github-actions github-actions bot added commit-queue-failed and removed commit-queue labels Nov 10, 2020
@github-actions
Copy link

@github-actions github-actions bot commented Nov 10, 2020

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

@benjamingr
Copy link
Member

@benjamingr benjamingr commented Nov 10, 2020

I'll resume CI and try landing with it

Copy link
Member

@juanarbol juanarbol left a comment

This is so goood, thank you 🎉

@benjamingr benjamingr added commit-queue semver-minor and removed commit-queue-failed labels Nov 10, 2020
@github-actions github-actions bot removed the commit-queue label Nov 10, 2020
@github-actions
Copy link

@github-actions github-actions bot commented Nov 10, 2020

Landed in 3c38445...60a97c0

@github-actions github-actions bot closed this Nov 10, 2020
nodejs-github-bot pushed a commit that referenced this issue Nov 10, 2020
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>
@benjamingr
Copy link
Member

@benjamingr benjamingr commented Nov 10, 2020

Thank you for your contribution @mattiasrunge and congratulations on your first contribution 🎉

@mattiasrunge
Copy link
Contributor Author

@mattiasrunge mattiasrunge commented Nov 10, 2020

Woho! Thank you @benjamingr!

codebytere pushed a commit that referenced this issue Nov 22, 2020
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>
codebytere added a commit that referenced this issue Nov 22, 2020
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
@codebytere codebytere mentioned this pull request Nov 22, 2020
codebytere added a commit that referenced this issue Nov 24, 2020
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
codebytere added a commit that referenced this issue Nov 24, 2020
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
codebytere added a commit that referenced this issue Nov 24, 2020
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
targos pushed a commit that referenced this issue May 1, 2021
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>
@danielleadams danielleadams mentioned this pull request May 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready readline semver-minor