7
0
mirror of https://github.com/ChristianLight/tutor.git synced 2024-06-16 12:22:22 +00:00
tutor/tutor/fmt.py

49 lines
837 B
Python
Raw Normal View History

import click
STDOUT = None
def title(text):
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")
2019-05-11 22:10:14 +00:00
def echo_info(text):
echo(info(text))
def info(text):
return click.style(text, fg="blue")
def error(text):
return click.style(text, fg="red")
2019-05-11 22:10:14 +00:00
def echo_error(text):
echo(error(text), err=True)
def command(text):
return click.style(text, fg="magenta")
def question(text):
return click.style(text, fg="yellow")
2019-05-11 22:10:14 +00:00
def echo_alert(text):
echo_error(alert(text))
2019-05-11 22:10:14 +00:00
def alert(text):
return click.style("⚠️ " + text, fg="yellow", bold=True)
2019-05-11 22:10:14 +00:00
def echo(text, err=False):
click.echo(text, file=STDOUT, err=err)