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

mattiasrunge
Copy link
Contributor

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 Issues and PRs related to the built-in readline module. label May 31, 2020
doc/api/readline.md Outdated Show resolved Hide resolved
Copy link
Member

@benjamingr benjamingr left a 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

@mattiasrunge
Copy link
Contributor Author

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

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

@nodejs/readline

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

@benjamingr benjamingr left a 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

Copy link
Member

@BridgeAR BridgeAR left a 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.

@mattiasrunge
Copy link
Contributor Author

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

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.

@mattiasrunge
Copy link
Contributor Author

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

@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 <[email protected]>
@mattiasrunge
Copy link
Contributor Author

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 PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Nov 8, 2020
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 8, 2020
@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 added the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 10, 2020
@github-actions github-actions bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Nov 10, 2020
@github-actions
Copy link
Contributor

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

I'll resume CI and try landing with it

@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@juanarbol juanarbol left a 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 🎉

@benjamingr benjamingr added commit-queue Add this label to land a pull request using GitHub Actions. semver-minor PRs that contain new features and should be released in the next minor version. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Nov 10, 2020
@github-actions github-actions bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 10, 2020
@github-actions
Copy link
Contributor

Landed in 3c38445...60a97c0

@github-actions github-actions bot closed this Nov 10, 2020
nodejs-github-bot pushed a commit that referenced this pull request 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 <[email protected]>

PR-URL: #33675
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
@benjamingr
Copy link
Member

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

@mattiasrunge
Copy link
Contributor Author

Woho! Thank you @benjamingr!

codebytere pushed a commit that referenced this pull request 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 <[email protected]>

PR-URL: #33675
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
codebytere added a commit that referenced this pull request 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 pull request 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 pull request 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 pull request 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 pull request 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 <[email protected]>

PR-URL: #33675
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
@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 PRs that have at least one approval, no pending requests for changes, and a CI started. readline Issues and PRs related to the built-in readline module. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.