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

Issue 5114 - Add greeting and Ctrl-V help to REPL #5159

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

rdeforest
Copy link
Contributor

An implementation of #5114.

The REPL now starts with a greeting:

$ bin/coffee

CoffeeScript v2.3.2 REPL, running on NodeJS v11.9.0.
Press Ctrl-V to enter and exit multi-line mode.
Enter '.help' to see a list of repl commands.

coffee>

And the first time the user presses Ctrl-V they get a reminder to press it again to leave multi-line mode:

coffee> console.log """
(Press Ctrl-V again to exit multi-line mode.)
------> console.log """
.......   Hello world!
....... """
Hello world!
undefined
------>

In the example above, the multi-line prompt after undefined demonstrates that the coffee> prompt was changed in-place the second time, just like the original behavior.

I didn't add any tests since this is essentially a cosmetic change. I also only did enough testing to make sure it did what I expected on NodeJS versions 6 and 11.

Is there a better place to put UI strings such as the greeting and hint? (I'm used to having them kept in non-code files elsewhere in projects, like ${PROJECT_ROOT}/data/messages.)

@jashkenas
Copy link
Owner

Just a preference — but I generally prefer no "greeting" on my command-line tools. If you use them regularly, it gets old incredibly fast.

@rdeforest
Copy link
Contributor Author

Reasonable. If someone wants to know more about the tool they can check coffee -v, coffee -h and node -v, and if they want a more verbose startup they can wrap or modify the tool themselves. I've amended the PR accordingly.

@edemaine
Copy link
Contributor

edemaine commented Feb 11, 2019

The downside to removing the greeting is that it's pretty non-obvious that CTRL-V exists at all. (I learned of it only a few weeks ago, after years of CoffeeScript.) Without some greeting, this doesn't fix #5114. Would a shorter greeting be reasonable? Alternatively, we can look for a more documentation-based fix as suggested in this comment.

@GeoffreyBooth
Copy link
Collaborator

So what does this PR do now? Show a hint about Ctrl-V once the user already presses Ctrl-V, to tell them to repeat the key combination to turn off multiline mode? If someone already knows about Ctrl-V to enter multiline mode, wouldn’t they also know how to toggle it back off?

@Inve1951
Copy link
Contributor

So what does this PR do now? Show a hint about Ctrl-V once the user already presses Ctrl-V, to tell them to repeat the key combination to turn off multiline mode?

Yes. First time they enter it each REPL session.

If someone already knows about Ctrl-V to enter multiline mode, wouldn’t they also know how to toggle it back off?

Certainly shouldn't take more than a few seconds to figgure it out. At least that's how I remember it.

Btw, this addition from line 5 is redundant: process = require 'process'

@ranska
Copy link

ranska commented Jan 3, 2021

Hello this is open since 2019 and all check have passed. Is there any specifics reasons to not merge it ?

@GeoffreyBooth
Copy link
Collaborator

Hello this is open since 2019 and all check have passed. Is there any specifics reasons to not merge it ?

There are some usability concerns raised on this thread that I don't think have yet been addressed.

One further one is, how does the regular Node REPL handle this and can we take the same approach?

@rdeforest
Copy link
Contributor Author

how does the regular Node REPL handle this?

$ node
Welcome to Node.js v14.13.1.
Type ".help" for more information.
> .help
.break    Sometimes you get stuck, this gets you out
.clear    Alias for .break
.editor   Enter editor mode
.exit     Exit the REPL
.help     Print this help message
.load     Load JS from a file into the REPL session
.save     Save all evaluated commands in this REPL session to a file

Press Ctrl+C to abort current expression, Ctrl+D to exit the REPL
> .editor
// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)

>

Even though I'm the author of this PR, I find the comments of @jashkenas and @GeoffreyBooth compelling and am in favor of keeping the REPL quiet. It is more in line with The Unix Way.

@GeoffreyBooth
Copy link
Collaborator

Even though I’m the author of this PR, I find the comments of @jashkenas and @GeoffreyBooth compelling and am in favor of keeping the REPL quiet.

So should we close this PR and the accompanying issue? We can always reopen if there’s a proposal for a UX that everyone’s happy with.

@rdeforest
Copy link
Contributor Author

Yes, and #5114.

@mrmowgli
Copy link
Contributor

Just a 2 cents here, but wouldn't it be good to include these messages to ease newbie usage? Having to google something esoteric three seconds after using it seems like a non-starter for a lot of people. Python is a great example of tons of usage and still including the messages for their repl.

@edemaine
Copy link
Contributor

+1 for the original version of this PR (as documented in the original post).

I use CoffeeScript every day, but I use the REPL pretty rarely, and I still struggle to remember the right key for CTRL-V. So I think it would help veterans too, not just new users.

I don't see the message being annoying; it's pretty short. Maybe folks would be happier if there were an environment variable and/or a command-line option to disable it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants