mirror of
https://github.com/onyx-and-iris/slobs-cli.git
synced 2025-06-27 15:20:24 +01:00
add studiomode command group
minor bump
This commit is contained in:
parent
cc2eda00a5
commit
14f89dd636
@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "slobs-cli"
|
||||
version = "0.6.1"
|
||||
version = "0.7.0"
|
||||
description = "A command line application for Streamlabs Desktop"
|
||||
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]
|
||||
dependencies = ["pyslobs>=2.0.4", "asyncclick>=8.1.8"]
|
||||
|
@ -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)
|
Loading…
x
Reference in New Issue
Block a user