4 Commits

Author SHA1 Message Date
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
11 changed files with 30 additions and 15 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.2"

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

@@ -9,4 +9,6 @@ err = Console(stderr=True, style='bold red')
def highlight(ctx: typer.Context, text: str) -> str: def highlight(ctx: typer.Context, text: str) -> str:
"""Highlight text using the current context's style.""" """Highlight text using the current context's style."""
if ctx.obj['style'].name == 'no_colour':
return text
return f'[{ctx.obj["style"].highlight}]{text}[/{ctx.obj["style"].highlight}]' return f'[{ctx.obj["style"].highlight}]{text}[/{ctx.obj["style"].highlight}]'

View File

@@ -72,7 +72,7 @@ def list_(
table.add_row( table.add_row(
filter['filterName'], filter['filterName'],
util.snakecase_to_titlecase(filter['filterKind']), util.snakecase_to_titlecase(filter['filterKind']),
util.check_mark(filter['filterEnabled']), util.check_mark(ctx, filter['filterEnabled']),
'\n'.join( '\n'.join(
[ [
f'{util.snakecase_to_titlecase(k):<20} {v:>10}' f'{util.snakecase_to_titlecase(k):<20} {v:>10}'

View File

@@ -68,7 +68,7 @@ def list_(
table.add_row( table.add_row(
str(item_id), str(item_id),
group_name, group_name,
util.check_mark(is_enabled), util.check_mark(ctx, is_enabled),
) )
console.out.print(table) console.out.print(table)

View File

@@ -81,7 +81,7 @@ def list_(
input_mark = '' input_mark = ''
try: try:
input_muted = ctx.obj['obsws'].get_input_mute(name=input_name).input_muted input_muted = ctx.obj['obsws'].get_input_mute(name=input_name).input_muted
input_mark = util.check_mark(input_muted) input_mark = util.check_mark(ctx, input_muted)
except obsws.error.OBSSDKRequestError as e: except obsws.error.OBSSDKRequestError as e:
if e.code == 604: # Input does not support audio if e.code == 604: # Input does not support audio
input_mark = 'N/A' input_mark = 'N/A'

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

@@ -50,13 +50,13 @@ def list_(
if uuid: if uuid:
table.add_row( table.add_row(
scene_name, scene_name,
util.check_mark(scene_name == active_scene, empty_if_false=True), util.check_mark(ctx, scene_name == active_scene, empty_if_false=True),
scene_uuid, scene_uuid,
) )
else: else:
table.add_row( table.add_row(
scene_name, scene_name,
util.check_mark(scene_name == active_scene, empty_if_false=True), util.check_mark(ctx, scene_name == active_scene, empty_if_false=True),
) )
console.out.print(table) console.out.print(table)

View File

@@ -107,7 +107,7 @@ def list_(
str(group_item_id), str(group_item_id),
group_item_name, group_item_name,
item_name, item_name,
util.check_mark(is_enabled and group_item_enabled), util.check_mark(ctx, is_enabled and group_item_enabled),
group_item_source_uuid, group_item_source_uuid,
) )
else: else:
@@ -115,7 +115,7 @@ def list_(
str(group_item_id), str(group_item_id),
group_item_name, group_item_name,
item_name, item_name,
util.check_mark(is_enabled and group_item_enabled), util.check_mark(ctx, is_enabled and group_item_enabled),
) )
else: else:
if uuid: if uuid:
@@ -123,7 +123,7 @@ def list_(
str(item_id), str(item_id),
item_name, item_name,
'', '',
util.check_mark(is_enabled), util.check_mark(ctx, is_enabled),
source_uuid, source_uuid,
) )
else: else:
@@ -131,7 +131,7 @@ def list_(
str(item_id), str(item_id),
item_name, item_name,
'', '',
util.check_mark(is_enabled), util.check_mark(ctx, is_enabled),
) )
console.out.print(table) console.out.print(table)

View File

@@ -2,17 +2,19 @@
import os import os
import typer
def snakecase_to_titlecase(snake_str: str) -> str: def snakecase_to_titlecase(snake_str: str) -> str:
"""Convert a snake_case string to a title case string.""" """Convert a snake_case string to a title case string."""
return snake_str.replace('_', ' ').title() 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.""" """Return a check mark or cross mark based on the boolean value."""
if empty_if_false and not value: if empty_if_false and not value:
return '' return ''
if os.getenv('NO_COLOR', '') != '': if os.getenv('NO_COLOR', '') != '' or ctx.obj['style'].name == 'no_colour':
return '' if value else '' return '' if value else ''
return '' if value else '' return '' if value else ''