6 Commits

Author SHA1 Message Date
55a7da67db reword 2025-06-22 10:19:46 +01:00
7bec573ef9 by setting values in the default style to 'none' we avoid the rich markup errors in console.highlight
add comment to util.check_mark and test only NO_COLOR

patch bump
2025-06-22 10:14:46 +01:00
55e60ff977 in case NO_COLOR is set manually
patch bump
2025-06-22 02:49:32 +01:00
922efddf7a 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
2025-06-22 01:57:58 +01:00
4a0147aa8a import as version 2025-06-22 00:38:19 +01:00
cec76df1d1 add 0.18.0 to CHANGELOG 2025-06-21 23:47:19 +01:00
6 changed files with 22 additions and 7 deletions

View File

@@ -5,6 +5,15 @@ 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/), 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). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
# [0.18.0] - 2025-06-21
### Added
- Various colouring styles, see [Style](https://github.com/onyx-and-iris/obsws-cli/tree/main?tab=readme-ov-file#style)
- colouring is applied to list tables as well as highlighted information in stdout/stderr output.
- table border styling may be optionally disabled with the --no-border flag.
# [0.17.3] - 2025-06-20 # [0.17.3] - 2025-06-20
### Added ### Added

View File

@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2025-present onyx-and-iris <code@onyxandiris.online> # SPDX-FileCopyrightText: 2025-present onyx-and-iris <code@onyxandiris.online>
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
__version__ = "0.17.6" __version__ = "0.18.3"

View File

@@ -7,7 +7,7 @@ from typing import Annotated
import obsws_python as obsws import obsws_python as obsws
import typer import typer
from obsws_cli.__about__ import __version__ as obsws_cli_version from obsws_cli.__about__ import __version__ as version
from . import console, settings, styles from . import console, settings, styles
from .alias import RootTyperAliasGroup from .alias import RootTyperAliasGroup
@@ -37,7 +37,7 @@ for sub_typer in (
def version_callback(value: bool): def version_callback(value: bool):
"""Show the version of the CLI.""" """Show the version of the CLI."""
if value: if value:
console.out.print(f'obsws-cli version: {obsws_cli_version}') console.out.print(f'obsws-cli version: {version}')
raise typer.Exit() raise typer.Exit()

View File

@@ -35,7 +35,9 @@ def list_(ctx: typer.Context):
for profile in resp.profiles: for profile in resp.profiles:
table.add_row( table.add_row(
profile, profile,
util.check_mark(profile == resp.current_profile_name, empty_if_false=True), util.check_mark(
ctx, profile == resp.current_profile_name, empty_if_false=True
),
) )
console.out.print(table) console.out.print(table)

View File

@@ -21,9 +21,9 @@ class Style:
name: str = 'no_colour' name: str = 'no_colour'
description: str = 'Style disabled' description: str = 'Style disabled'
border: str | None = None border: str = 'none'
column: str | None = None column: str = 'none'
highlight: str | None = None highlight: str = 'none'
no_border: bool = False no_border: bool = False
def __post_init__(self): def __post_init__(self):

View File

@@ -13,6 +13,10 @@ def check_mark(value: bool, empty_if_false: bool = False) -> str:
if empty_if_false and not value: if empty_if_false and not value:
return '' return ''
# rich gracefully handles the absence of colour throughout the rest of the application,
# but here we must handle it manually.
# If NO_COLOR is set, we return plain text symbols.
# Otherwise, we return coloured symbols.
if os.getenv('NO_COLOR', '') != '': if os.getenv('NO_COLOR', '') != '':
return '' if value else '' return '' if value else ''
return '' if value else '' return '' if value else ''