python-cli-ui icon indicating copy to clipboard operation
python-cli-ui copied to clipboard

Add more functions

Open dmerejkowsky opened this issue 5 years ago • 2 comments

I often end up needed those in projects that depend on cli-ui, so might as well add them here.

First, h1, h2 and h3:

h1("Section")
h2("Sub section")
h2("Sub sub section")
Section
=======

Sub section
--------------

Sub sub section
+++++++++++++
  • Then hr which would print an horizontal line taking all of the horizontal space
info("foo")
hr()
foo
-----------------------------------------------

I'm open to suggestions regarding naming (re-using HTML syntax may not be the best idea)

Also, maybe we need h3 to h6 ?

dmerejkowsky avatar Mar 05 '20 13:03 dmerejkowsky

bro, coool library, nice job

greysign avatar Mar 29 '20 15:03 greysign

Other idea. Have a way to log multiple messages on the same line:

def erase_last_line() -> None:
    terminal_size = shutil.get_terminal_size()
    ui.info(" " * terminal_size.columns, end="\r")

ui.info("doing stuff", end="\n")
# ...
erase_last_line()

It's a pattern I've been using a few times

dmerejkowsky avatar Nov 19 '20 12:11 dmerejkowsky