diff --git a/obsws_cli/__about__.py b/obsws_cli/__about__.py index 57900d2..d02145c 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.24.3' +__version__ = '0.24.4' diff --git a/obsws_cli/scene.py b/obsws_cli/scene.py index 5758e84..6e6979e 100644 --- a/obsws_cli/scene.py +++ b/obsws_cli/scene.py @@ -70,14 +70,14 @@ def list_( def current( ctx: typer.Context, preview: Annotated[ - bool, typer.Option(help='Get the preview scene instead of the program scene') + bool, + typer.Option( + help='Get the preview scene instead of the program scene', + callback=validate.studio_mode_enabled, + ), ] = False, ): """Get the current program scene or preview scene.""" - if preview and not validate.studio_mode_enabled(ctx): - console.err.print('Studio mode is not enabled, cannot get preview scene.') - raise typer.Exit(1) - if preview: resp = ctx.obj['obsws'].get_current_preview_scene() console.out.print( @@ -103,14 +103,13 @@ def switch( ], preview: Annotated[ bool, - typer.Option(help='Switch to the preview scene instead of the program scene'), + typer.Option( + help='Switch to the preview scene instead of the program scene', + callback=validate.studio_mode_enabled, + ), ] = False, ): """Switch to a scene.""" - if preview and not validate.studio_mode_enabled(ctx): - console.err.print('Studio mode is not enabled, cannot set the preview scene.') - raise typer.Exit(1) - if preview: ctx.obj['obsws'].set_current_preview_scene(scene_name) console.out.print( diff --git a/obsws_cli/validate.py b/obsws_cli/validate.py index eb94df6..9d66195 100644 --- a/obsws_cli/validate.py +++ b/obsws_cli/validate.py @@ -40,10 +40,15 @@ def scene_in_scenes(ctx: typer.Context, scene_name: Optional[str]) -> str | None return scene_name -def studio_mode_enabled(ctx: typer.Context) -> bool: - """Check if studio mode is enabled.""" +def studio_mode_enabled(ctx: typer.Context, preview: bool) -> bool: + """Ensure studio mode is enabled if preview option is used.""" resp = ctx.obj['obsws'].get_studio_mode_enabled() - return resp.studio_mode_enabled + if preview and not resp.studio_mode_enabled: + console.err.print( + 'Studio mode is disabled. This action requires it to be enabled.' + ) + raise typer.Exit(1) + return preview def scene_collection_in_scene_collections(