diff --git a/CHANGELOG.md b/CHANGELOG.md index eab7d87..e05bba2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -# [0.17.0] - 2025-06-20 +# [0.17.3] - 2025-06-20 ### Added @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - scene list no longer prints the UUIDs by default, enable it with the --uuid flag. +- if NO_COLOR is set, print colourless check and cross marks in tables. ### Fixed diff --git a/obsws_cli/__about__.py b/obsws_cli/__about__.py index 3bcd6bd..9013f9f 100644 --- a/obsws_cli/__about__.py +++ b/obsws_cli/__about__.py @@ -1,4 +1,4 @@ # SPDX-FileCopyrightText: 2025-present onyx-and-iris # # SPDX-License-Identifier: MIT -__version__ = "0.17.2" +__version__ = "0.17.3" diff --git a/obsws_cli/filter.py b/obsws_cli/filter.py index fbc6a65..431917f 100644 --- a/obsws_cli/filter.py +++ b/obsws_cli/filter.py @@ -65,7 +65,7 @@ def list_( table.add_row( filter['filterName'], util.snakecase_to_titlecase(filter['filterKind']), - ':white_heavy_check_mark:' if filter['filterEnabled'] else ':x:', + util.check_mark(filter['filterEnabled']), '\n'.join( [ f'{util.snakecase_to_titlecase(k):<20} {v:>10}' diff --git a/obsws_cli/group.py b/obsws_cli/group.py index 54601ab..e61f260 100644 --- a/obsws_cli/group.py +++ b/obsws_cli/group.py @@ -5,7 +5,7 @@ from typing import Annotated, Optional import typer from rich.table import Table -from . import console, validate +from . import console, util, validate from .alias import AliasGroup from .protocols import DataclassProtocol @@ -61,7 +61,7 @@ def list_( table.add_row( str(item_id), group_name, - ':white_heavy_check_mark:' if is_enabled else ':x:', + util.check_mark(is_enabled), ) console.out.print(table) diff --git a/obsws_cli/input.py b/obsws_cli/input.py index aeed06b..e7ebb25 100644 --- a/obsws_cli/input.py +++ b/obsws_cli/input.py @@ -81,7 +81,7 @@ def list_( input_mark = '' try: input_muted = ctx.obj.get_input_mute(name=input_name).input_muted - input_mark = ':white_heavy_check_mark:' if input_muted else ':x:' + input_mark = util.check_mark(input_muted) except obsws.error.OBSSDKRequestError as e: if e.code == 604: # Input does not support audio input_mark = 'N/A' diff --git a/obsws_cli/profile.py b/obsws_cli/profile.py index 5996ae8..d60e2dd 100644 --- a/obsws_cli/profile.py +++ b/obsws_cli/profile.py @@ -5,7 +5,7 @@ from typing import Annotated import typer from rich.table import Table -from . import console, validate +from . import console, util, validate from .alias import AliasGroup app = typer.Typer(cls=AliasGroup) @@ -32,7 +32,7 @@ def list_(ctx: typer.Context): for profile in resp.profiles: table.add_row( profile, - ':white_heavy_check_mark:' if profile == resp.current_profile_name else '', + util.check_mark(profile == resp.current_profile_name), ) console.out.print(table) diff --git a/obsws_cli/scene.py b/obsws_cli/scene.py index 328f3ea..92d217a 100644 --- a/obsws_cli/scene.py +++ b/obsws_cli/scene.py @@ -5,7 +5,7 @@ from typing import Annotated import typer from rich.table import Table -from . import console, validate +from . import console, util, validate from .alias import AliasGroup app = typer.Typer(cls=AliasGroup) @@ -55,13 +55,13 @@ def list_( if uuid: table.add_row( scene_output, - ':white_heavy_check_mark:' if scene_name == active_scene else '', + util.check_mark(scene_name == active_scene), scene_uuid, ) else: table.add_row( scene_output, - ':white_heavy_check_mark:' if scene_name == active_scene else '', + util.check_mark(scene_name == active_scene), ) console.out.print(table) diff --git a/obsws_cli/sceneitem.py b/obsws_cli/sceneitem.py index 0a7cc1a..532be1f 100644 --- a/obsws_cli/sceneitem.py +++ b/obsws_cli/sceneitem.py @@ -5,7 +5,7 @@ from typing import Annotated, Optional import typer from rich.table import Table -from . import console, validate +from . import console, util, validate from .alias import AliasGroup app = typer.Typer(cls=AliasGroup) @@ -102,9 +102,7 @@ def list_( str(group_item_id), group_item_name, item_name, - ':white_heavy_check_mark:' - if is_enabled and group_item_enabled - else ':x:', + util.check_mark(is_enabled and group_item_enabled), group_item_source_uuid, ) else: @@ -112,9 +110,7 @@ def list_( str(group_item_id), group_item_name, item_name, - ':white_heavy_check_mark:' - if is_enabled and group_item_enabled - else ':x:', + util.check_mark(is_enabled and group_item_enabled), ) else: if uuid: @@ -122,7 +118,7 @@ def list_( str(item_id), item_name, '', - ':white_heavy_check_mark:' if is_enabled else ':x:', + util.check_mark(is_enabled), source_uuid, ) else: @@ -130,7 +126,7 @@ def list_( str(item_id), item_name, '', - ':white_heavy_check_mark:' if is_enabled else ':x:', + util.check_mark(is_enabled), ) console.out.print(table) diff --git a/obsws_cli/util.py b/obsws_cli/util.py index 07482d5..abb4e94 100644 --- a/obsws_cli/util.py +++ b/obsws_cli/util.py @@ -1,6 +1,15 @@ """module contains utility functions for the obsws_cli package.""" +import os -def snakecase_to_titlecase(snake_str): + +def snakecase_to_titlecase(snake_str: str) -> str: """Convert a snake_case string to a title case string.""" return snake_str.replace('_', ' ').title() + + +def check_mark(value: bool) -> str: + """Return a check mark or cross mark based on the boolean value.""" + if os.getenv('NO_COLOR') is not None: + return '✓' if value else '✗' + return '✅' if value else '❌'