Don't use irrelevant class for colors

This commit is contained in:
ItsDrike 2021-01-14 14:48:22 +01:00
parent a47c660fff
commit 28f9eb1545
No known key found for this signature in database
GPG key ID: 252D306F545351FC
2 changed files with 24 additions and 23 deletions

View file

@ -1,21 +1,22 @@
from src.util import command from src.util import command
class Color: def get_256_color(color):
def get_256_color(color): """Get color using tput (256-colors base)"""
"""Get color using tput (256-colors base)""" return command.get_output(f"tput setaf {color}")
return command.get_output(f"tput setaf {color}")
def get_special_color(index):
"""Get special colors using tput (like bold, etc..)"""
return command.get_output(f"tput {index}")
RED = get_256_color(196) def get_special_color(index):
BLUE = get_256_color(51) """Get special colors using tput (like bold, etc..)"""
GREEN = get_256_color(46) return command.get_output(f"tput {index}")
YELLOW = get_256_color(226)
GOLD = get_256_color(214)
GREY = get_256_color(238)
RESET = get_special_color("sgr0")
BOLD = get_special_color("bold") RED = get_256_color(196)
BLUE = get_256_color(51)
GREEN = get_256_color(46)
YELLOW = get_256_color(226)
GOLD = get_256_color(214)
GREY = get_256_color(238)
RESET = get_special_color("sgr0")
BOLD = get_special_color("bold")

View file

@ -1,36 +1,36 @@
import typing as t import typing as t
from src.util.color import Color from src.util import color
class Print: class Print:
def question(question: str, options: t.Optional[list] = None) -> None: def question(question: str, options: t.Optional[list] = None) -> None:
"""Print syntax for question with optional `options` to it""" """Print syntax for question with optional `options` to it"""
text = [f"{Color.GREEN} // {question}{Color.RESET}"] text = [f"{color.GREEN} // {question}{color.RESET}"]
if options: if options:
for option in options: for option in options:
text.append(f"{Color.GREEN} # {option}{Color.RESET}") text.append(f"{color.GREEN} # {option}{color.RESET}")
print("\n".join(text)) print("\n".join(text))
def action(action: str) -> None: def action(action: str) -> None:
"""Print syntax for action""" """Print syntax for action"""
print(f"{Color.GOLD} >> {action}{Color.RESET}") print(f"{color.GOLD} >> {action}{color.RESET}")
def err(text: str) -> None: def err(text: str) -> None:
"""Print syntax for error""" """Print syntax for error"""
print(f"\n{Color.RED} !! {text}{Color.RESET}") print(f"\n{color.RED} !! {text}{color.RESET}")
def cancel(text: str) -> None: def cancel(text: str) -> None:
"""Print syntax for cancellation""" """Print syntax for cancellation"""
print(f"{Color.GREY} >> {text}{Color.RESET}") print(f"{color.GREY} >> {text}{color.RESET}")
def comment(text: str) -> None: def comment(text: str) -> None:
"""Print syntax for comments""" """Print syntax for comments"""
print(f"{Color.GREY} // {text}{Color.RESET}") print(f"{color.GREY} // {text}{color.RESET}")
def warning(text: str) -> None: def warning(text: str) -> None:
"""Print syntax for warnings""" """Print syntax for warnings"""
print(f"{Color.YELLOW} ** {text}{Color.RESET}") print(f"{color.YELLOW} ** {text}{color.RESET}")
class Input: class Input: