From 105aaf29b7a35615b4d709bfad17e319389ba81b Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Thu, 17 Jul 2025 04:34:44 +0100 Subject: [PATCH] keep the exit codes simple (0 or 1) --- obsws_cli/enum.py | 6 ------ obsws_cli/filter.py | 12 ++++++------ obsws_cli/scene.py | 6 +++--- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/obsws_cli/enum.py b/obsws_cli/enum.py index fca0fb5..94786d9 100644 --- a/obsws_cli/enum.py +++ b/obsws_cli/enum.py @@ -8,9 +8,3 @@ class ExitCode(IntEnum): SUCCESS = 0 ERROR = auto() - INVALID_ARGUMENT = auto() - INVALID_PARAMETER = auto() - NOT_FOUND = auto() - ALREADY_EXISTS = auto() - TIMEOUT = auto() - UNKNOWN_ERROR = auto() diff --git a/obsws_cli/filter.py b/obsws_cli/filter.py index 0d86e4f..596fd4f 100644 --- a/obsws_cli/filter.py +++ b/obsws_cli/filter.py @@ -3,7 +3,7 @@ from typing import Annotated, Optional import obsws_python as obsws -from cyclopts import App, Argument, CycloptsError, Parameter +from cyclopts import App, Argument, Parameter from rich.table import Table from rich.text import Text @@ -37,7 +37,7 @@ def list_( if e.code == 600: raise OBSWSCLIError( f'No source found by the name of [yellow]{source_name}[/yellow].', - code=ExitCode.NOT_FOUND, + code=ExitCode.ERROR, ) else: raise @@ -104,9 +104,9 @@ def enable( ): """Enable a filter for a source.""" if _get_filter_enabled(ctx, source_name, filter_name): - raise CycloptsError( + raise OBSWSCLIError( f'Filter [yellow]{filter_name}[/yellow] is already enabled for source [yellow]{source_name}[/yellow]', - console=console.err, + code=ExitCode.ERROR, ) ctx.client.set_source_filter_enabled(source_name, filter_name, enabled=True) @@ -131,9 +131,9 @@ def disable( ): """Disable a filter for a source.""" if not _get_filter_enabled(ctx, source_name, filter_name): - raise CycloptsError( + raise OBSWSCLIError( f'Filter [yellow]{filter_name}[/yellow] is already disabled for source [yellow]{source_name}[/yellow]', - console=console.err, + code=ExitCode.ERROR, ) ctx.client.set_source_filter_enabled(source_name, filter_name, enabled=False) diff --git a/obsws_cli/scene.py b/obsws_cli/scene.py index 66e2f08..5072afa 100644 --- a/obsws_cli/scene.py +++ b/obsws_cli/scene.py @@ -72,7 +72,7 @@ def current( if preview and not validate.studio_mode_enabled(ctx): raise OBSWSCLIError( 'Studio mode is not enabled, cannot get preview scene.', - code=ExitCode.INVALID_PARAMETER, + code=ExitCode.ERROR, ) if preview: @@ -102,13 +102,13 @@ def switch( if preview and not validate.studio_mode_enabled(ctx): raise OBSWSCLIError( 'Studio mode is not enabled, cannot switch to preview scene.', - code=ExitCode.INVALID_PARAMETER, + code=ExitCode.ERROR, ) if not validate.scene_in_scenes(ctx, scene_name): raise OBSWSCLIError( f'Scene [yellow]{scene_name}[/yellow] not found.', - code=ExitCode.NOT_FOUND, + code=ExitCode.ERROR, ) if preview: