mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-05-29 20:30:48 +00:00
0a670d7ead
Annotations were generated with pyannotate: https://github.com/dropbox/pyannotate We are running in strict mode, which is awesome! This affects a large part of the code base, which might be an issue for people running a fork of Tutor. Nonetheless, the behavior should not be affected. If anything, this process has helped find and resolve a few type-related bugs. Thus, this is not considered as a breaking change.
49 lines
969 B
Python
49 lines
969 B
Python
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:
|
|
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:
|
|
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))
|
|
|
|
|
|
def alert(text: str) -> str:
|
|
return click.style("⚠️ " + text, fg="yellow", bold=True)
|
|
|
|
|
|
def echo(text: str, err: bool = False) -> None:
|
|
click.echo(text, file=STDOUT, err=err)
|