psysh icon indicating copy to clipboard operation
psysh copied to clipboard

Improves console output

Open nunomaduro opened this issue 3 years ago • 7 comments

After https://github.com/laravel/tinker/pull/152, as requested, I've made this pull request that updates the console output of the shell class. Here are the changes, and feel free to "check" the ones you agree with, and leave uncheck the changes you think still need some discussion.

  • [x] As requested, we've left the library's author name unchanged, and simply updated the color from "blue" to "cyan".
  • [ ] Next, the PROMPT, BUFF_PROMPT, REPLAY, and RETVAL, have been simplified to a single char. Also, the RETVALis displayed ongray`, so the output result gets highlighted.
  • [ ] After, when errors/warnings occur, I've added margin-top and margin-bottom ( a new line ), so the terminal has some space to breathe.
  • [x] Also, the "Goodbye" message, or any message coming from "BreakException" are now displayed as regular "INFO" information, as they are not errors.
  • [x] Next, I've displayed the errors differently, using a "CLASS_NAME" followed by the original message for regular exceptions, and using "ERROR_TYPE" followed by the original message for PHP errors/warnings.
  • [x] I've removed the "in Psy Shell code" wording, as it doesn't add anything.
  • [x] Finally, I've ensured error/warnings messages always end with a "dot", and contain relative paths instead of absolute paths.

Here is the described changes, but comparing the before vs after:

1 2 3 4 5

nunomaduro avatar Jul 29 '22 16:07 nunomaduro

Hi @bobthecow, so, here is the list of applied changes, after your first feedback in the pull request:

  • The on line 1 is only displayed when line > 1:
Screenshot 2022-08-01 at 08 59 19
  • Named styles - the blue info background and the gray thing - got converted to "named" styles: info and whisper. Note that, the whisper only actually uses gray if gray is available.

  • The symbol now uses the whisper style. ( can you test this one? ).

  • The credits are displayed on whisper: Screenshot 2022-08-01 at 09 11 52

nunomaduro avatar Aug 01 '22 08:08 nunomaduro

The ⏎ symbol now uses the whisper style. ( can you test this one? ).

This happens when stdout doesn't end with a newline, so you can test with echo "foo".

bobthecow avatar Aug 01 '22 17:08 bobthecow

@bobthecow Ready for your second review. ✅

Do you know why a few jobs are failing?

nunomaduro avatar Aug 01 '22 20:08 nunomaduro

@nunomaduro it's caused by indentation of closing HEREDOC (EOF). Relaxed syntax was introduced in 7.3 and that's why those versions are green in Actions 🙂

Wirone avatar Aug 01 '22 20:08 Wirone

@bobthecow Let me know if something else is missing here. ✔️

nunomaduro avatar Aug 07 '22 22:08 nunomaduro

Sorry, I've been camping and unable to connect to the internet. I'll take a look soon :)

bobthecow avatar Aug 08 '22 02:08 bobthecow

Perfect. No worries, and be sure to enjoy your camping. 🏕

nunomaduro avatar Aug 08 '22 08:08 nunomaduro

How do we feel about whispering the prompt as well?

Screen Shot 2022-08-13 at 3 54 06 PM

bobthecow avatar Aug 13 '22 19:08 bobthecow

Thanks for all your work on this :)

bobthecow avatar Aug 13 '22 20:08 bobthecow