mirror of
https://github.com/onyx-and-iris/slobs-cli.git
synced 2026-04-21 00:13:39 +00:00
replace terminaltables with rich tables.
allow rich to handle all console output. util.check_mark is now used to pass back colourless check/cross marks if NO_COLOR is set or --style/SLOBS_STYLE was not set.
This commit is contained in:
21
src/slobs_cli/console.py
Normal file
21
src/slobs_cli/console.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""module for console output handling."""
|
||||
|
||||
import asyncclick as click
|
||||
from rich.console import Console
|
||||
|
||||
out = Console()
|
||||
err = Console(stderr=True, style='bold red')
|
||||
|
||||
|
||||
def highlight(ctx: click.Context, text: str) -> str:
|
||||
"""Highlight text for console output."""
|
||||
if ctx.obj['style'].name == 'no_colour':
|
||||
return text
|
||||
return f'[{ctx.obj["style"].highlight}]{text}[/{ctx.obj["style"].highlight}]'
|
||||
|
||||
|
||||
def warning(ctx: click.Context, text: str) -> str:
|
||||
"""Format warning text for console output."""
|
||||
if ctx.obj['style'].name == 'no_colour':
|
||||
return text
|
||||
return f'[magenta]{text}[/magenta]'
|
||||
Reference in New Issue
Block a user