remocolab icon indicating copy to clipboard operation
remocolab copied to clipboard

Using the "rich" module to make program output prettier

Open ochen1 opened this issue 5 years ago • 2 comments

rich is a Python module I have grown very fond of. It gives immediate beauty to any Python project, and even goes as far as making the exceptions beautiful.

It comes with support for all types of terminals and stdouts, making printing colors and different fonts a breeze. This includes the old terminal we are all used to, and Jupyter notebook output cells. It's syntax is simple, beautiful, and easy to use. Here is a sample:

from rich.console import Console
console = Console()
console.log("This is a [bold]log[/bold]. Time and line numbers will be shown.")
console.print("remocolab installed [green bold]successfully[/]! :tada:")

image

With all of this simplicity, there is still a lot of control over the program's output.

The package size is under 50MB, so it shouldn't impact the lightweightedness of this program much.

Can I implement this into remocolab? I think it would make the output of the program much more attractive.

😍

EDIT: rich installed in under 2s with pip on my system.

ochen1 avatar Dec 27 '20 16:12 ochen1

Another primary reason why I want to use rich is that its (beautiful 😍) progress bars offer support on Deepnote (and all Jupyter notebooks, I presume). Deepnote doesn't support ipywidgets. rich uses low-level APIs (ie. stdin, stdout).

ochen1 avatar Dec 27 '20 17:12 ochen1

I don't think remocolab need to print text with colors. It just prints key fingerprint of host, passwords and ssh command.

demotomohiro avatar Dec 28 '20 04:12 demotomohiro