"""This module provides classes and methods for beautifully formatted output to stdout.This includes printing tables and grids, formatting dates and eliding strings."""from__future__importannotationsimportenumfromdatetimeimportdatetimefromtypingimportCallable,Iterableimportclickfromrich.consoleimportConsole,ConsoleOptions,RenderResultfromrich.measureimportMeasurementfromrich.styleimportStylefromrich.tableimportColumn,Tablefromrich.textimportText
[docs]defecho(message:str,nl:bool=True,prefix:Prefix=Prefix.NONE)->None:""" Print a message to stdout. :param message: The string to output. :param nl: Whether to end with a new line. :param prefix: Any prefix to output before the message, """ifprefixisPrefix.Ok:pre=click.style("✓",fg="green")+" "elifprefixisPrefix.Warn:pre=click.style("!",fg="red")+" "elifprefixisPrefix.Info:pre="- "else:pre=""click.echo(f"{pre}{message}",nl=nl)
[docs]definfo(message:str,nl:bool=True)->None:""" Print an info message to stdout. Will be prefixed with a dash. :param message: The string to output. :param nl: Whether to end with a new line. """echo(message,nl=nl,prefix=Prefix.Info)
[docs]defwarn(message:str,nl:bool=True)->None:""" Print a warning to stdout. Will be prefixed with an exclamation mark. :param message: The string to output. :param nl: Whether to end with a new line. """echo(message,nl=nl,prefix=Prefix.Warn)
[docs]defok(message:str,nl:bool=True)->None:""" Print a confirmation to stdout. Will be prefixed with a checkmark. :param message: The string to output. :param nl: Whether to end with a new line. """echo(message,nl=nl,prefix=Prefix.Ok)