mirror of
https://github.com/ChristianLight/tutor.git
synced 2025-01-05 23:20:40 +00:00
c4c12b0ab8
Clarify a few variable names, make code more modular. Also, the Renderer class now makes more sense as a singleton. We took the opportunity to delete quite a lot of code.
49 lines
831 B
Python
49 lines
831 B
Python
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")
|
|
|
|
|
|
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")
|
|
|
|
|
|
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")
|
|
|
|
|
|
def echo_alert(text):
|
|
echo(alert(text))
|
|
|
|
|
|
def alert(text):
|
|
return click.style("⚠️ " + text, fg="yellow", bold=True)
|
|
|
|
|
|
def echo(text, err=False):
|
|
click.echo(text, file=STDOUT, err=err)
|