echo.py 1.41 KB
Newer Older
Alan Marchiori's avatar
Alan Marchiori committed
1
2
3
"""Various helpers to handle icons and colors
FUTURE: create style files.
"""
Alan Marchiori's avatar
initial  
Alan Marchiori committed
4
5
6
import click

def echo(*args, **kwargs):
Alan Marchiori's avatar
Alan Marchiori committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    return click.echo(
        #\uf0d0 = magic
        click.style("\uf0d0 ", bold=True) + \
        " ".join(map(str, args)), **kwargs)
def confirm(*args, **kwargs):
    return click.confirm(
        #\u2754 = question mark
        click.style("\u2753 ", bold=True) + \
        " ".join(map(str, args)), **kwargs)

def prompt(*args, **kwargs):
    return click.prompt(*args, **kwargs)

def success(*args, **kwargs):
    return click.echo(
        #\u2713 = checkmark
        click.style("\u2713 ", fg='green', bold=True) + \
        " ".join(map(str, args)), **kwargs)
Alan Marchiori's avatar
initial  
Alan Marchiori committed
25
26

def error(*args, **kwargs):
Alan Marchiori's avatar
Alan Marchiori committed
27
28
29
30
31
32
33
34
35
36
    return click.echo(
        #\u274c = cross mark
        click.style("\u274c ", fg='red', bold=True) + \
        " ".join(map(str, args)), **kwargs)

def error_confirm(*args, **kwargs):
    return click.confirm(
        #\u274c = cross mark
        click.style("\u274c ", fg='red', bold=True) + \
        " ".join(map(str, args)), **kwargs)
Alan Marchiori's avatar
initial  
Alan Marchiori committed
37
38

def warn(*args, **kwargs):
Alan Marchiori's avatar
Alan Marchiori committed
39
40
41
42
43
44
45
46
47
48
    return click.echo(
        #\u26A0 = warning mark
        click.style("\u26a0 ", fg='yellow', bold=True) + \
        " ".join(map(str, args)), **kwargs)

def warn_confirm (*args, **kwargs):
    return click.confirm(
        #\u26A0 = warning mark
        click.style("\u26a0 ", fg='yellow', bold=True) + \
        " ".join(map(str, args)), **kwargs)