clihelpers

class gonto.clihelpers.CSI_BGCOLOR(*values)

ANSI terminal background color sequences

BLACK = '\x1b[40m'
BLUE = '\x1b[44m'
CYAN = '\x1b[46m'
DEFAULT = '\x1b[49m'
GREEN = '\x1b[42m'
LIGHT_GRAY = '\x1b[47m'
MAGENTA = '\x1b[45m'
RED = '\x1b[41m'
YELLOW = '\x1b[43m'
class gonto.clihelpers.CSI_FGCOLOR(*values)

ANSI terminal foreground color sequences

BLACK = '\x1b[30m'
BLUE = '\x1b[34m'
CYAN = '\x1b[36m'
DEFAULT = '\x1b[39m'
GREEN = '\x1b[32m'
LIGHT_GRAY = '\x1b[37m'
MAGENTA = '\x1b[35m'
RED = '\x1b[31m'
YELLOW = '\x1b[33m'
class gonto.clihelpers.CSI_STYLE(*values)

ANSI terminal style sequences

BOLD = '\x1b[1m'
DIM = '\x1b[2m'
RESET = '\x1b[0m'
class gonto.clihelpers.ProgressBar(text: str = '', bar_width: int = 40, margin_left=0, use_ascii: bool = False)

Displays progression for log operation.

On TTYs it displays a progress bar, on non-interactive outputs it displays a simpler progress.

Example progress bar:

Downloading 'foobar.vhd'...
┫████████████▒░░░░░░░░░░░░░░░░┣ 46.50%

Example progress bar (with use_ascii=True):

Downloading 'foobar.vhd'...
[============>                ] 46.50%

Example on non-interactive outputs:

Downloading 'foobar.vhd'...
.....   5%
.....  10%
.....  15%
  [...]
..... 100%
Parameters:
  • text – The text displayed above the progress bar if any.

  • bar_width – The total bar width (including percent and spaces).

  • margin_left – Left indentation of the bar.

  • use_ascii – Use only ASCII characters to “draw” the bar.

finish() None

Finish the progress. Must be called once at the end.

start() None

Start the progress. Must be called once at start.

update(progress: float)

Update the progress.

Parameters:

progress – The new progress (number between 0.0 and 1.0).

gonto.clihelpers.print_block(text: str, fgcolor: CSI_FGCOLOR | None = None, bgcolor: CSI_BGCOLOR | None = None, width: int = 80) None

Print the given text in a block.

Parameters:
  • text – The text to print.

  • fgcolor – The text color.

  • bgcolor – The background color.

  • width – The width of terminal.

gonto.clihelpers.print_center(text: str, width: int = 80) None

Prints centered text.

Parameters:
  • text – The text to print.

  • width – The terminal width.

gonto.clihelpers.print_splashscreen(version: str | None = None) None

Prints Gonto’s logo and version (if provided).

Parameters:

version – Gonto version.

gonto.clihelpers.print_title(text: str, width: int = 80) None

Print a “title”.

Parameters:
  • text – The title to print.

  • width – The width of terminal.