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:
2025-06-22 02:52:27 +01:00
parent 6bcdd8391c
commit c02ffac403
10 changed files with 209 additions and 118 deletions

21
src/slobs_cli/console.py Normal file
View 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]'