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

[RFC]: add command to display command history in the REPL #2071

Open
3 tasks done
kgryte opened this issue Mar 27, 2024 · 0 comments
Open
3 tasks done

[RFC]: add command to display command history in the REPL #2071

kgryte opened this issue Mar 27, 2024 · 0 comments
Labels
difficulty: 3 Likely to be challenging but manageable. Enhancement Issue or pull request for enhancing existing functionality. JavaScript Issue involves or relates to JavaScript. Needs Discussion Needs further discussion. priority: Normal Normal priority concern or feature request. REPL Issue or pull request specific to the project REPL. RFC Request for comments. Feature requests and proposed changes.

Comments

@kgryte
Copy link
Member

kgryte commented Mar 27, 2024

Description

This RFC proposes adding support for displaying command history in the REPL. The behavior would be similar to that in IPython: https://ipython.readthedocs.io/en/stable/interactive/magics.html?highlight=magic#magic-history

Potential command signature:

history( [options] )
history( n[, options] )
history( start, stop[, options] )

with the ability to

  • print a specific number of lines n
  • print a range of lines [start, stop]

and options to

  • specify a regex to filter commands to include
  • specify a regex to filter commands to exclude
  • filter based on whether a command succeeded or failed (e.g., a success option)
  • enabling displaying prompts in the output (i.e., the -n option in IPython)
  • control the prompt display (e.g., similar to the p option in IPython, but where one can provide, say, In [%d]: to allow restarting the line numbers, which may be useful when printing REPL examples, etc)
  • include command results in the displayed output.

Related Issues

No.

Questions

  • Presumably, we could have a separate command for saving history to a file. IMO, we should separate the concerns of displaying history from saving history to a file. Whatever APIs we provide can leverage common infrastructure, but they should probably be separate user APIs, with their own set of options and concerns.
  • Including previous command results could be tricky. Maybe this is simple as moving the cursor up and then copying down, but I suspect that this could be more involved. And we cannot simply rely on inspecting the current values of workspace variables, as we'd want to capture the value of the variable at that point in history.
  • Presumably, if a user clears their command history, they shouldn't be able to display the cleared commands. But what if a user clears their terminal screen? How do we effectively capture results/outputs at the time of execution?

Other

No.

Checklist

  • I have read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
  • The issue name begins with RFC:.
@kgryte kgryte added Enhancement Issue or pull request for enhancing existing functionality. RFC Request for comments. Feature requests and proposed changes. Needs Discussion Needs further discussion. difficulty: 3 Likely to be challenging but manageable. REPL Issue or pull request specific to the project REPL. priority: Normal Normal priority concern or feature request. JavaScript Issue involves or relates to JavaScript. labels Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: 3 Likely to be challenging but manageable. Enhancement Issue or pull request for enhancing existing functionality. JavaScript Issue involves or relates to JavaScript. Needs Discussion Needs further discussion. priority: Normal Normal priority concern or feature request. REPL Issue or pull request specific to the project REPL. RFC Request for comments. Feature requests and proposed changes.
Projects
None yet
Development

No branches or pull requests

1 participant