-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
lib: repl add .load-editor feature #14503
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.
Needs docs.
Should be added under https://github.com/nodejs/node/blob/master/doc/api/repl.md#commands-and-special-keys
lib/repl.js
Outdated
@@ -1267,6 +1267,34 @@ function defineDefaultCommands(repl) { | |||
'// Entering editor mode (^D to finish, ^C to cancel)\n'); | |||
} | |||
}); | |||
|
|||
repl.defineCommand('load-editor', { | |||
help: 'Enter load and editor mode', |
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.
Maybe 'Load a file and enter editor mode'
?
ab13971
to
b217b78
Compare
Would you please update your summary to describe your PR? eg.
|
inputStream.write('.help\n'); | ||
assert(/\n\.say1 help for say1\n/.test(output), |
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.
any reason to have these modification? (a blank line and some spaces)
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.
because add .load-editor
command need more space for fomat
> .help
.break Sometimes you get stuck, this gets you out
.clear Break, and also clear the local context
.editor Enter editor mode
.exit Exit the repl
.help Print this help message
.load Load JS from a file into the REPL session
.load-editor Load a file and enter editor mode
.save Save all evaluated commands in this REPL session to a file
.say1 help for say1
.say2
>
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.
👌
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.
Thanks for this! It would seem that it needs a test.
@@ -34,8 +34,9 @@ r.defineCommand('say2', function() { | |||
this.displayPrompt(); | |||
}); | |||
|
|||
|
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.
How about this blank line?
97dc9c9
to
6137b22
Compare
@Fishrock123 I updated doc |
@@ -39,6 +39,7 @@ The following special commands are supported by all REPL instances: | |||
* `.load` - Load a file into the current REPL session. | |||
`> .load ./file/to/load.js` | |||
* `.editor` - Enter editor mode (`<ctrl>-D` to finish, `<ctrl>-C` to cancel) | |||
* `.load-editor` - Load a file and enter editor mode (`<ctrl>-D` to finish, `<ctrl>-C` to cancel) |
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.
It would be helpful to have an example
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.
Do you mean add an example in doc?
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.
Yeah. For instance, I presume there's a way of providing the file name to load but that's not captured here
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.
Just how .load
does it should be fine, the second line.
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.
Thanks, I have updated doc file
const stream = new common.ArrayStream(); | ||
const outputStream = new common.ArrayStream(); | ||
|
||
stream.write = () => { throw new Error('Writing not allowed!'); }; |
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.
stream.write = common.mustNotCall('writing not allowed');
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.
thank you for your help
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.
In #14861 (comment) I discovered that |
@lance |
@robbinhan I see your point. But it seems to me that, as-is, As I said in my PR, I didn't mean to encroach on what you were doing here, I was just trying to address #14022. I wasn't aware of your PR until a comment from @Fishrock123. I definitely appreciate your contribution here, and I am willing to go with whatever approach makes the most sense. In this case, I feel it's fixing |
@lance So, does improve |
@robbinhan in my opinion, yes. But I want to hear from other @nodejs/collaborators on it. |
I'm thinking that the other PR is likely the better option. Not quite ready to sign off on it tho. |
I looked at both of these and I am definitely in favor of #14861. As @lance already pointed out it is more like a bug fix instead of adding a new feature. @robbinhan I appreciate your work a lot nevertheless! |
Closing due to the already mentioned reasons. |
support input
.load-editor
in repl