upd console colouring

error messages now have style `bold red`
error highlights are now yellow

normal highlights are now green

patch bump
This commit is contained in:
onyx-and-iris 2025-06-06 20:53:35 +01:00
parent 44527b35e2
commit ddb92bb317
16 changed files with 111 additions and 65 deletions

View File

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

View File

@ -34,7 +34,7 @@ for sub_typer in (
app.add_typer(module.app, name=sub_typer)
out_console = Console()
err_console = Console(stderr=True)
err_console = Console(stderr=True, style='bold red')
def version_callback(value: bool):

View File

@ -12,7 +12,7 @@ from .alias import AliasGroup
app = typer.Typer(cls=AliasGroup)
out_console = Console()
err_console = Console(stderr=True)
err_console = Console(stderr=True, style='bold red')
@app.callback()
@ -39,13 +39,15 @@ def list_(
resp = ctx.obj.get_source_filter_list(source_name)
except obsws.error.OBSSDKRequestError as e:
if e.code == 600:
err_console.print(f"No source was found by the name of '{source_name}'.")
err_console.print(
f'No source was found by the name of [yellow]{source_name}[/yellow].'
)
raise typer.Exit(1)
else:
raise
if not resp.filters:
out_console.print(f'No filters found for source {source_name}')
out_console.print(f'No filters found for source [yellow]{source_name}[/yellow]')
raise typer.Exit()
table = Table(title=f'Filters for Source: {source_name}', padding=(0, 2))
@ -101,12 +103,14 @@ def enable(
"""Enable a filter for a source."""
if _get_filter_enabled(ctx, source_name, filter_name):
err_console.print(
f'Filter {filter_name} is already enabled for source {source_name}'
f'Filter [yellow]{filter_name}[/yellow] is already enabled for source [yellow]{source_name}[/yellow]'
)
raise typer.Exit(1)
ctx.obj.set_source_filter_enabled(source_name, filter_name, enabled=True)
out_console.print(f'Enabled filter {filter_name} for source {source_name}')
out_console.print(
f'Enabled filter [green]{filter_name}[/green] for source [green]{source_name}[/green]'
)
@app.command('disable | off')
@ -128,12 +132,14 @@ def disable(
"""Disable a filter for a source."""
if not _get_filter_enabled(ctx, source_name, filter_name):
err_console.print(
f'Filter {filter_name} is already disabled for source {source_name}'
f'Filter [yellow]{filter_name}[/yellow] is already disabled for source [yellow]{source_name}[/yellow]'
)
raise typer.Exit(1)
ctx.obj.set_source_filter_enabled(source_name, filter_name, enabled=False)
out_console.print(f'Disabled filter {filter_name} for source {source_name}')
out_console.print(
f'Disabled filter [green]{filter_name}[/green] for source [green]{source_name}[/green]'
)
@app.command('toggle | tg')
@ -158,9 +164,13 @@ def toggle(
ctx.obj.set_source_filter_enabled(source_name, filter_name, enabled=new_state)
if new_state:
out_console.print(f'Enabled filter {filter_name} for source {source_name}')
out_console.print(
f'Enabled filter [green]{filter_name}[/green] for source [green]{source_name}[/green]'
)
else:
out_console.print(f'Disabled filter {filter_name} for source {source_name}')
out_console.print(
f'Disabled filter [green]{filter_name}[/green] for source [green]{source_name}[/green]'
)
@app.command('status | ss')
@ -182,6 +192,10 @@ def status(
"""Get the status of a filter for a source."""
is_enabled = _get_filter_enabled(ctx, source_name, filter_name)
if is_enabled:
out_console.print(f'Filter {filter_name} is enabled for source {source_name}')
out_console.print(
f'Filter [green]{filter_name}[/green] is enabled for source [green]{source_name}[/green]'
)
else:
out_console.print(f'Filter {filter_name} is disabled for source {source_name}')
out_console.print(
f'Filter [green]{filter_name}[/green] is disabled for source [green]{source_name}[/green]'
)

View File

@ -12,7 +12,7 @@ from .protocols import DataclassProtocol
app = typer.Typer(cls=AliasGroup)
out_console = Console()
err_console = Console(stderr=True)
err_console = Console(stderr=True, style='bold red')
@app.callback()
@ -98,7 +98,9 @@ def show(
resp = ctx.obj.get_scene_item_list(scene_name)
if (group := _get_group(group_name, resp)) is None:
err_console.print(f"Group '{group_name}' not found in scene {scene_name}.")
err_console.print(
f'Group [yellow]{group_name}[/yellow] not found in scene [yellow]{scene_name}[/yellow].'
)
raise typer.Exit(1)
ctx.obj.set_scene_item_enabled(
@ -107,7 +109,7 @@ def show(
enabled=True,
)
out_console.print(f"Group '{group_name}' is now visible.")
out_console.print(f'Group [green]{group_name}[/green] is now visible.')
@app.command('hide | h')
@ -122,12 +124,14 @@ def hide(
):
"""Hide a group in a scene."""
if not validate.scene_in_scenes(ctx, scene_name):
err_console.print(f"Scene '{scene_name}' not found.")
err_console.print(f'Scene [yellow]{scene_name}[/yellow] not found.')
raise typer.Exit(1)
resp = ctx.obj.get_scene_item_list(scene_name)
if (group := _get_group(group_name, resp)) is None:
err_console.print(f"Group '{group_name}' not found in scene {scene_name}.")
err_console.print(
f'Group [yellow]{group_name}[/yellow] not found in scene [yellow]{scene_name}[/yellow].'
)
raise typer.Exit(1)
ctx.obj.set_scene_item_enabled(
@ -136,7 +140,7 @@ def hide(
enabled=False,
)
out_console.print(f"Group '{group_name}' is now hidden.")
out_console.print(f'Group [green]{group_name}[/green] is now hidden.')
@app.command('toggle | tg')
@ -151,12 +155,14 @@ def toggle(
):
"""Toggle a group in a scene."""
if not validate.scene_in_scenes(ctx, scene_name):
err_console.print(f"Scene '{scene_name}' not found.")
err_console.print(f'Scene [yellow]{scene_name}[/yellow] not found.')
raise typer.Exit(1)
resp = ctx.obj.get_scene_item_list(scene_name)
if (group := _get_group(group_name, resp)) is None:
err_console.print(f"Group '{group_name}' not found in scene {scene_name}.")
err_console.print(
f'Group [yellow]{group_name}[/yellow] not found in scene [yellow]{scene_name}[/yellow].'
)
raise typer.Exit(1)
new_state = not group.get('sceneItemEnabled')
@ -167,9 +173,9 @@ def toggle(
)
if new_state:
out_console.print(f"Group '{group_name}' is now visible.")
out_console.print(f'Group [green]{group_name}[/green] is now visible.')
else:
out_console.print(f"Group '{group_name}' is now hidden.")
out_console.print(f'Group [green]{group_name}[/green] is now hidden.')
@app.command('status | ss')
@ -184,12 +190,14 @@ def status(
):
"""Get the status of a group in a scene."""
if not validate.scene_in_scenes(ctx, scene_name):
err_console.print(f"Scene '{scene_name}' not found.")
err_console.print(f'Scene [yellow]{scene_name}[/yellow] not found.')
raise typer.Exit(1)
resp = ctx.obj.get_scene_item_list(scene_name)
if (group := _get_group(group_name, resp)) is None:
err_console.print(f"Group '{group_name}' not found in scene {scene_name}.")
err_console.print(
f'Group [yellow]{group_name}[/yellow] not found in scene [yellow]{scene_name}[/yellow].'
)
raise typer.Exit(1)
enabled = ctx.obj.get_scene_item_enabled(
@ -198,6 +206,6 @@ def status(
)
if enabled.scene_item_enabled:
out_console.print(f"Group '{group_name}' is now visible.")
out_console.print(f'Group [green]{group_name}[/green] is now visible.')
else:
out_console.print(f"Group '{group_name}' is now hidden.")
out_console.print(f'Group [green]{group_name}[/green] is now hidden.')

View File

@ -10,7 +10,7 @@ from .alias import AliasGroup
app = typer.Typer(cls=AliasGroup)
out_console = Console()
err_console = Console(stderr=True)
err_console = Console(stderr=True, style='bold red')
@app.callback()

View File

@ -11,7 +11,7 @@ from .alias import AliasGroup
app = typer.Typer(cls=AliasGroup)
out_console = Console()
err_console = Console(stderr=True)
err_console = Console(stderr=True, style='bold red')
@app.callback()

View File

@ -11,7 +11,7 @@ from .alias import AliasGroup
app = typer.Typer(cls=AliasGroup)
out_console = Console()
err_console = Console(stderr=True)
err_console = Console(stderr=True, style='bold red')
@app.callback()
@ -60,16 +60,18 @@ def switch(
):
"""Switch to a profile."""
if not validate.profile_exists(ctx, profile_name):
err_console.print(f"Profile '{profile_name}' not found.")
err_console.print(f'Profile [yellow]{profile_name}[/yellow] not found.')
raise typer.Exit(1)
resp = ctx.obj.get_profile_list()
if resp.current_profile_name == profile_name:
err_console.print(f"Profile '{profile_name}' is already the current profile.")
err_console.print(
f'Profile [yellow]{profile_name}[/yellow] is already the current profile.'
)
raise typer.Exit(1)
ctx.obj.set_current_profile(profile_name)
out_console.print(f"Switched to profile '{profile_name}'.")
out_console.print(f'Switched to profile [green]{profile_name}[/green].')
@app.command('create | new')
@ -82,11 +84,11 @@ def create(
):
"""Create a new profile."""
if validate.profile_exists(ctx, profile_name):
err_console.print(f"Profile '{profile_name}' already exists.")
err_console.print(f'Profile [yellow]{profile_name}[/yellow] already exists.')
raise typer.Exit(1)
ctx.obj.create_profile(profile_name)
out_console.print(f"Created profile '{profile_name}'.")
out_console.print(f'Created profile [green]{profile_name}[/green].')
@app.command('remove | rm')
@ -99,8 +101,8 @@ def remove(
):
"""Remove a profile."""
if not validate.profile_exists(ctx, profile_name):
err_console.print(f"Profile '{profile_name}' not found.")
err_console.print(f'Profile [yellow]{profile_name}[/yellow] not found.')
raise typer.Exit(1)
ctx.obj.remove_profile(profile_name)
out_console.print(f"Removed profile '{profile_name}'.")
out_console.print(f'Removed profile [green]{profile_name}[/green].')

View File

@ -10,7 +10,7 @@ from .alias import AliasGroup
app = typer.Typer(cls=AliasGroup)
out_console = Console()
err_console = Console(stderr=True)
err_console = Console(stderr=True, style='bold red')
@app.callback()
@ -61,11 +61,21 @@ def open(
if not source_name:
source_name = ctx.obj.get_current_program_scene().scene_name
ctx.obj.open_source_projector(
source_name=source_name,
monitor_index=monitor_index,
)
monitors = ctx.obj.get_monitor_list().monitors
for monitor in monitors:
if monitor['monitorIndex'] == monitor_index:
ctx.obj.open_source_projector(
source_name=source_name,
monitor_index=monitor_index,
)
out_console.print(
f'Opened projector for source [bold]{source_name}[/] on monitor [bold]{monitor_index}[/].'
)
out_console.print(
f'Opened projector for source [green]{source_name}[/] on monitor [green]{monitor["monitorName"]}[/].'
)
break
else:
err_console.print(
f'Monitor with index [yellow]{monitor_index}[/yellow] not found.'
)
raise typer.Exit(code=1)

View File

@ -10,7 +10,7 @@ from .alias import AliasGroup
app = typer.Typer(cls=AliasGroup)
out_console = Console()
err_console = Console(stderr=True)
err_console = Console(stderr=True, style='bold red')
@app.callback()
@ -49,7 +49,9 @@ def stop(ctx: typer.Context):
raise typer.Exit(1)
resp = ctx.obj.stop_record()
out_console.print(f'Recording stopped successfully. Saved to: {resp.output_path}')
out_console.print(
f'Recording stopped successfully. Saved to: [green]{resp.output_path}[/green]'
)
@app.command('toggle | tg')
@ -125,5 +127,5 @@ def directory(
out_console.print(f'Recording directory updated to: {record_directory}')
else:
out_console.print(
f'Recording directory: {ctx.obj.get_record_directory().record_directory}'
f'Recording directory: [green]{ctx.obj.get_record_directory().record_directory}[/green]'
)

View File

@ -7,7 +7,7 @@ from .alias import AliasGroup
app = typer.Typer(cls=AliasGroup)
out_console = Console()
err_console = Console(stderr=True)
err_console = Console(stderr=True, style='bold red')
@app.callback()

View File

@ -11,7 +11,7 @@ from .alias import AliasGroup
app = typer.Typer(cls=AliasGroup)
out_console = Console()
err_console = Console(stderr=True)
err_console = Console(stderr=True, style='bold red')
@app.callback()
@ -78,12 +78,12 @@ def switch(
raise typer.Exit(1)
if not validate.scene_in_scenes(ctx, scene_name):
err_console.print(f"Scene '{scene_name}' not found.")
err_console.print(f'Scene [yellow]{scene_name}[/yellow] not found.')
raise typer.Exit(1)
if preview:
ctx.obj.set_current_preview_scene(scene_name)
out_console.print(f'Switched to preview scene: {scene_name}')
out_console.print(f'Switched to preview scene: [green]{scene_name}[/green]')
else:
ctx.obj.set_current_program_scene(scene_name)
out_console.print(f'Switched to program scene: {scene_name}')
out_console.print(f'Switched to program scene: [green]{scene_name}[/green]')

View File

@ -11,7 +11,7 @@ from .alias import AliasGroup
app = typer.Typer(cls=AliasGroup)
out_console = Console()
err_console = Console(stderr=True)
err_console = Console(stderr=True, style='bold red')
@app.callback()
@ -49,7 +49,9 @@ def switch(
):
"""Switch to a scene collection."""
if not validate.scene_collection_in_scene_collections(ctx, scene_collection_name):
err_console.print(f"Scene collection '{scene_collection_name}' not found.")
err_console.print(
f'Scene collection [yellow]{scene_collection_name}[/yellow] not found.'
)
raise typer.Exit(1)
current_scene_collection = (
@ -57,12 +59,14 @@ def switch(
)
if scene_collection_name == current_scene_collection:
err_console.print(
f'Scene collection "{scene_collection_name}" is already active.'
f'Scene collection [yellow]{scene_collection_name}[/yellow] is already active.'
)
raise typer.Exit(1)
ctx.obj.set_current_scene_collection(scene_collection_name)
out_console.print(f"Switched to scene collection '{scene_collection_name}'")
out_console.print(
f'Switched to scene collection [green]{scene_collection_name}[/green].'
)
@app.command('create | new')
@ -74,8 +78,12 @@ def create(
):
"""Create a new scene collection."""
if validate.scene_collection_in_scene_collections(ctx, scene_collection_name):
err_console.print(f"Scene collection '{scene_collection_name}' already exists.")
err_console.print(
f'Scene collection [yellow]{scene_collection_name}[/yellow] already exists.'
)
raise typer.Exit(1)
ctx.obj.create_scene_collection(scene_collection_name)
out_console.print(f'Created scene collection {scene_collection_name}')
out_console.print(
f'Created scene collection [green]{scene_collection_name}[/green].'
)

View File

@ -79,14 +79,16 @@ def save(
match e.code:
case 403:
err_console.print(
'The image format (file extension) must be included in the file name '
'The [yellow]image format[/yellow] (file extension) must be included in the file name, '
"for example: '/path/to/screenshot.png'.",
)
raise typer.Exit(1)
case 600:
err_console.print(f"No source was found by the name of '{source_name}'")
err_console.print(
f'No source was found by the name of [yellow]{source_name}[/yellow]'
)
raise typer.Exit(1)
case _:
raise
out_console.print(f"Screenshot saved to [bold]'{output_path}'[/bold].")
out_console.print(f'Screenshot saved to [green]{output_path}[/green].')

View File

@ -7,7 +7,7 @@ from .alias import AliasGroup
app = typer.Typer(cls=AliasGroup)
out_console = Console()
err_console = Console(stderr=True)
err_console = Console(stderr=True, style='bold red')
@app.callback()

View File

@ -7,7 +7,7 @@ from .alias import AliasGroup
app = typer.Typer(cls=AliasGroup)
out_console = Console()
err_console = Console(stderr=True)
err_console = Console(stderr=True, style='bold red')
@app.callback()

View File

@ -7,7 +7,7 @@ from .alias import AliasGroup
app = typer.Typer(cls=AliasGroup)
out_console = Console()
err_console = Console(stderr=True)
err_console = Console(stderr=True, style='bold red')
@app.callback()