check if we're in colourless mode before passing back highlighted text.

pass context to check_mark so we can do the same there.

Fixes  rich.errors.MarkupError
This commit is contained in:
2025-06-22 01:57:58 +01:00
parent 4a0147aa8a
commit 922efddf7a
9 changed files with 18 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
"""module contains utility functions for the obsws_cli package."""
import os
import typer
def snakecase_to_titlecase(snake_str: str) -> str:
@@ -8,11 +8,11 @@ def snakecase_to_titlecase(snake_str: str) -> str:
return snake_str.replace('_', ' ').title()
def check_mark(value: bool, empty_if_false: bool = False) -> str:
def check_mark(ctx: typer.Context, value: bool, empty_if_false: bool = False) -> str:
"""Return a check mark or cross mark based on the boolean value."""
if empty_if_false and not value:
return ''
if os.getenv('NO_COLOR', '') != '':
if ctx.obj['style'].name == 'no_colour':
return '' if value else ''
return '' if value else ''