6
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-09-22 09:29:02 +00:00
tutor/tutor/fmt.py

49 lines
969 B
Python
Raw Normal View History

import click
STDOUT = None
def title(text: str) -> str:
indent = 8
separator = "=" * (len(text) + 2 * indent)
message = "{separator}\n{indent}{text}\n{separator}".format(
separator=separator, indent=" " * indent, text=text
)
return click.style(message, fg="green")
def echo_info(text: str) -> None:
2019-05-11 22:10:14 +00:00
echo(info(text))
def info(text: str) -> str:
return click.style(text, fg="blue")
def error(text: str) -> str:
return click.style(text, fg="red")
def echo_error(text: str) -> None:
2019-05-11 22:10:14 +00:00
echo(error(text), err=True)
def command(text: str) -> str:
return click.style(text, fg="magenta")
def question(text: str) -> str:
return click.style(text, fg="yellow")
def echo_alert(text: str) -> None:
echo_error(alert(text))
2019-05-11 22:10:14 +00:00
def alert(text: str) -> str:
return click.style("⚠️ " + text, fg="yellow", bold=True)
2019-05-11 22:10:14 +00:00
def echo(text: str, err: bool = False) -> None:
click.echo(text, file=STDOUT, err=err)