Skip to content

Add ability to suppress .commands in REPL #57989

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

Open
TheBrenny opened this issue Apr 23, 2025 · 0 comments
Open

Add ability to suppress .commands in REPL #57989

TheBrenny opened this issue Apr 23, 2025 · 0 comments
Labels
feature request Issues that request new features to be added to Node.js.

Comments

@TheBrenny
Copy link

TheBrenny commented Apr 23, 2025

What is the problem this feature will solve?

I'm building a custom shell-like REPL for an application that's written in Javascript. To achieve this, I'm using the REPL module because it's more feature-rich than the readline module (for example, using ctrl+r (and looking through the Node code, I couldn't actually find where this functionality is defined...)). It's also much easier to work with than the readline module.

However, I'm trying to secure the application as best as possible so my users don't fall into holes when trying to execute commands, and so I'm restricting access to the REPL dot commands of .editor, .help, etc. I would also like to take advantage of the .commands in my own eval function so I can also extend the functionality of my REPL too.

Specifically: the problem this feature will solve is to allow .commands through to the eval function. Some guard rails will probably need to be put in place (such as making sure the default eval isn't being used, or writing a warning in the docs).

What is the feature you are proposing to solve the problem?

Add an optional property to the ReplOptions called nativeDotCommands (or whatever fits), and adjust the if statement to account for this property (and likely adjustments to other parts of the codebase)

What alternatives have you considered?

Currently, I'm setting repl.commands = {} to remove all the commands, however of course this is throwing an error from my linter because that property is read-only. I can suppress the error, but that still doesn't allow me to use .commands within my application. So far, this is the best work around I've got (short of rewriting and using the readline module.)

@TheBrenny TheBrenny added the feature request Issues that request new features to be added to Node.js. label Apr 23, 2025
@github-project-automation github-project-automation bot moved this to Awaiting Triage in Node.js feature requests Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Issues that request new features to be added to Node.js.
Projects
Status: Awaiting Triage
Development

No branches or pull requests

1 participant