mirror of
https://github.com/onyx-and-iris/slobs-cli.git
synced 2026-04-21 00:13:39 +00:00
set default values for no_colour style to 'none'.
This fixes rich markup error ensure errors are written without colour if NO_COLOR is set
This commit is contained in:
@@ -1,21 +1,21 @@
|
||||
"""module for console output handling."""
|
||||
|
||||
import os
|
||||
|
||||
import asyncclick as click
|
||||
from rich.console import Console
|
||||
|
||||
out = Console()
|
||||
err = Console(stderr=True, style='bold red')
|
||||
err = Console(
|
||||
stderr=True, style='bold red' if os.getenv('NO_COLOR', '') != '' else 'none'
|
||||
)
|
||||
|
||||
|
||||
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]'
|
||||
return f'[{ctx.obj["style"].warning}]{text}[/{ctx.obj["style"].warning}]'
|
||||
|
||||
Reference in New Issue
Block a user