mirror of
https://github.com/onyx-and-iris/slobs-cli.git
synced 2026-04-18 06:53:39 +00:00
add studiomode command group
minor bump
This commit is contained in:
@@ -4,5 +4,6 @@ from .record import record
|
||||
from .replaybuffer import replaybuffer
|
||||
from .scene import scene
|
||||
from .stream import stream
|
||||
from .studiomode import studiomode
|
||||
|
||||
__all__ = ["cli", "scene", "stream", "record", "audio", "replaybuffer"]
|
||||
__all__ = ["cli", "scene", "stream", "record", "audio", "replaybuffer", "studiomode"]
|
||||
|
||||
100
src/slobs_cli/studiomode.py
Normal file
100
src/slobs_cli/studiomode.py
Normal file
@@ -0,0 +1,100 @@
|
||||
import asyncclick as click
|
||||
from anyio import create_task_group
|
||||
from pyslobs import TransitionsService
|
||||
|
||||
from .cli import cli
|
||||
|
||||
|
||||
@cli.group()
|
||||
def studiomode():
|
||||
"""Studio mode management commands."""
|
||||
|
||||
|
||||
@studiomode.command()
|
||||
@click.pass_context
|
||||
async def enable(ctx: click.Context):
|
||||
"""Enable studio mode."""
|
||||
|
||||
conn = ctx.obj["connection"]
|
||||
ts = TransitionsService(conn)
|
||||
|
||||
async def _run():
|
||||
current_state = await ts.get_model()
|
||||
if current_state.studio_mode:
|
||||
conn.close()
|
||||
raise click.Abort(click.style("Studio mode is already enabled.", fg="red"))
|
||||
|
||||
await ts.enable_studio_mode()
|
||||
click.echo("Studio mode enabled successfully.")
|
||||
conn.close()
|
||||
|
||||
async with create_task_group() as tg:
|
||||
tg.start_soon(conn.background_processing)
|
||||
tg.start_soon(_run)
|
||||
|
||||
|
||||
@studiomode.command()
|
||||
@click.pass_context
|
||||
async def disable(ctx: click.Context):
|
||||
"""Disable studio mode."""
|
||||
|
||||
conn = ctx.obj["connection"]
|
||||
ts = TransitionsService(conn)
|
||||
|
||||
async def _run():
|
||||
current_state = await ts.get_model()
|
||||
if not current_state.studio_mode:
|
||||
conn.close()
|
||||
raise click.Abort(click.style("Studio mode is already disabled.", fg="red"))
|
||||
|
||||
await ts.disable_studio_mode()
|
||||
click.echo("Studio mode disabled successfully.")
|
||||
conn.close()
|
||||
|
||||
async with create_task_group() as tg:
|
||||
tg.start_soon(conn.background_processing)
|
||||
tg.start_soon(_run)
|
||||
|
||||
|
||||
@studiomode.command()
|
||||
@click.pass_context
|
||||
async def status(ctx: click.Context):
|
||||
"""Check the status of studio mode."""
|
||||
|
||||
conn = ctx.obj["connection"]
|
||||
ts = TransitionsService(conn)
|
||||
|
||||
async def _run():
|
||||
current_state = await ts.get_model()
|
||||
if current_state.studio_mode:
|
||||
click.echo("Studio mode is currently enabled.")
|
||||
else:
|
||||
click.echo("Studio mode is currently disabled.")
|
||||
conn.close()
|
||||
|
||||
async with create_task_group() as tg:
|
||||
tg.start_soon(conn.background_processing)
|
||||
tg.start_soon(_run)
|
||||
|
||||
|
||||
@studiomode.command()
|
||||
@click.pass_context
|
||||
async def toggle(ctx: click.Context):
|
||||
"""Toggle studio mode."""
|
||||
|
||||
conn = ctx.obj["connection"]
|
||||
ts = TransitionsService(conn)
|
||||
|
||||
async def _run():
|
||||
current_state = await ts.get_model()
|
||||
if current_state.studio_mode:
|
||||
await ts.disable_studio_mode()
|
||||
click.echo("Studio mode disabled successfully.")
|
||||
else:
|
||||
await ts.enable_studio_mode()
|
||||
click.echo("Studio mode enabled successfully.")
|
||||
conn.close()
|
||||
|
||||
async with create_task_group() as tg:
|
||||
tg.start_soon(conn.background_processing)
|
||||
tg.start_soon(_run)
|
||||
Reference in New Issue
Block a user