mirror of
https://github.com/onyx-and-iris/obsws-cli.git
synced 2025-07-19 03:11:47 +00:00
keep the exit codes simple (0 or 1)
This commit is contained in:
parent
eb34a1833f
commit
105aaf29b7
@ -8,9 +8,3 @@ class ExitCode(IntEnum):
|
|||||||
|
|
||||||
SUCCESS = 0
|
SUCCESS = 0
|
||||||
ERROR = auto()
|
ERROR = auto()
|
||||||
INVALID_ARGUMENT = auto()
|
|
||||||
INVALID_PARAMETER = auto()
|
|
||||||
NOT_FOUND = auto()
|
|
||||||
ALREADY_EXISTS = auto()
|
|
||||||
TIMEOUT = auto()
|
|
||||||
UNKNOWN_ERROR = auto()
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
from typing import Annotated, Optional
|
from typing import Annotated, Optional
|
||||||
|
|
||||||
import obsws_python as obsws
|
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.table import Table
|
||||||
from rich.text import Text
|
from rich.text import Text
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ def list_(
|
|||||||
if e.code == 600:
|
if e.code == 600:
|
||||||
raise OBSWSCLIError(
|
raise OBSWSCLIError(
|
||||||
f'No source found by the name of [yellow]{source_name}[/yellow].',
|
f'No source found by the name of [yellow]{source_name}[/yellow].',
|
||||||
code=ExitCode.NOT_FOUND,
|
code=ExitCode.ERROR,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
@ -104,9 +104,9 @@ def enable(
|
|||||||
):
|
):
|
||||||
"""Enable a filter for a source."""
|
"""Enable a filter for a source."""
|
||||||
if _get_filter_enabled(ctx, source_name, filter_name):
|
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]',
|
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)
|
ctx.client.set_source_filter_enabled(source_name, filter_name, enabled=True)
|
||||||
@ -131,9 +131,9 @@ def disable(
|
|||||||
):
|
):
|
||||||
"""Disable a filter for a source."""
|
"""Disable a filter for a source."""
|
||||||
if not _get_filter_enabled(ctx, source_name, filter_name):
|
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]',
|
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)
|
ctx.client.set_source_filter_enabled(source_name, filter_name, enabled=False)
|
||||||
|
@ -72,7 +72,7 @@ def current(
|
|||||||
if preview and not validate.studio_mode_enabled(ctx):
|
if preview and not validate.studio_mode_enabled(ctx):
|
||||||
raise OBSWSCLIError(
|
raise OBSWSCLIError(
|
||||||
'Studio mode is not enabled, cannot get preview scene.',
|
'Studio mode is not enabled, cannot get preview scene.',
|
||||||
code=ExitCode.INVALID_PARAMETER,
|
code=ExitCode.ERROR,
|
||||||
)
|
)
|
||||||
|
|
||||||
if preview:
|
if preview:
|
||||||
@ -102,13 +102,13 @@ def switch(
|
|||||||
if preview and not validate.studio_mode_enabled(ctx):
|
if preview and not validate.studio_mode_enabled(ctx):
|
||||||
raise OBSWSCLIError(
|
raise OBSWSCLIError(
|
||||||
'Studio mode is not enabled, cannot switch to preview scene.',
|
'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):
|
if not validate.scene_in_scenes(ctx, scene_name):
|
||||||
raise OBSWSCLIError(
|
raise OBSWSCLIError(
|
||||||
f'Scene [yellow]{scene_name}[/yellow] not found.',
|
f'Scene [yellow]{scene_name}[/yellow] not found.',
|
||||||
code=ExitCode.NOT_FOUND,
|
code=ExitCode.ERROR,
|
||||||
)
|
)
|
||||||
|
|
||||||
if preview:
|
if preview:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user