read conn from closure

This commit is contained in:
onyx-and-iris 2025-06-10 13:26:20 +01:00
parent ad6c0bb042
commit 7227183073
3 changed files with 13 additions and 13 deletions

View File

@ -1,6 +1,6 @@
[project] [project]
name = "slobs-cli" name = "slobs-cli"
version = "0.3.0" version = "0.3.1"
description = "A command line application for Streamlabs Desktop" description = "A command line application for Streamlabs Desktop"
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }] authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]
dependencies = ["pyslobs>=2.0.4", "asyncclick>=8.1.8"] dependencies = ["pyslobs>=2.0.4", "asyncclick>=8.1.8"]

View File

@ -43,7 +43,7 @@ async def current(ctx: click.Context):
conn = ctx.obj["connection"] conn = ctx.obj["connection"]
ss = ScenesService(conn) ss = ScenesService(conn)
async def _run(conn): async def _run():
active_scene = await ss.active_scene() active_scene = await ss.active_scene()
if active_scene: if active_scene:
click.echo( click.echo(
@ -55,7 +55,7 @@ async def current(ctx: click.Context):
async with create_task_group() as tg: async with create_task_group() as tg:
tg.start_soon(conn.background_processing) tg.start_soon(conn.background_processing)
tg.start_soon(_run, conn) tg.start_soon(_run)
@scene.command() @scene.command()
@ -67,7 +67,7 @@ async def switch(ctx: click.Context, scene_name: str):
conn = ctx.obj["connection"] conn = ctx.obj["connection"]
ss = ScenesService(conn) ss = ScenesService(conn)
async def _run(conn): async def _run():
scenes = await ss.get_scenes() scenes = await ss.get_scenes()
for scene in scenes: for scene in scenes:
if scene.name == scene_name: if scene.name == scene_name:
@ -83,4 +83,4 @@ async def switch(ctx: click.Context, scene_name: str):
async with create_task_group() as tg: async with create_task_group() as tg:
tg.start_soon(conn.background_processing) tg.start_soon(conn.background_processing)
tg.start_soon(_run, conn) tg.start_soon(_run)

View File

@ -18,7 +18,7 @@ async def start(ctx: click.Context):
conn = ctx.obj["connection"] conn = ctx.obj["connection"]
ss = StreamingService(conn) ss = StreamingService(conn)
async def _run(conn): async def _run():
current_state = await ss.get_model() current_state = await ss.get_model()
active = current_state.streaming_status != "offline" active = current_state.streaming_status != "offline"
@ -32,7 +32,7 @@ async def start(ctx: click.Context):
async with create_task_group() as tg: async with create_task_group() as tg:
tg.start_soon(conn.background_processing) tg.start_soon(conn.background_processing)
tg.start_soon(_run, conn) tg.start_soon(_run)
@stream.command() @stream.command()
@ -43,7 +43,7 @@ async def stop(ctx: click.Context):
conn = ctx.obj["connection"] conn = ctx.obj["connection"]
ss = StreamingService(conn) ss = StreamingService(conn)
async def _run(conn): async def _run():
current_state = await ss.get_model() current_state = await ss.get_model()
active = current_state.streaming_status != "offline" active = current_state.streaming_status != "offline"
@ -57,7 +57,7 @@ async def stop(ctx: click.Context):
async with create_task_group() as tg: async with create_task_group() as tg:
tg.start_soon(conn.background_processing) tg.start_soon(conn.background_processing)
tg.start_soon(_run, conn) tg.start_soon(_run)
@stream.command() @stream.command()
@ -68,7 +68,7 @@ async def status(ctx: click.Context):
conn = ctx.obj["connection"] conn = ctx.obj["connection"]
ss = StreamingService(conn) ss = StreamingService(conn)
async def _run(conn): async def _run():
current_state = await ss.get_model() current_state = await ss.get_model()
status = current_state.streaming_status status = current_state.streaming_status
click.echo(f"Current stream status: {status}") click.echo(f"Current stream status: {status}")
@ -76,7 +76,7 @@ async def status(ctx: click.Context):
async with create_task_group() as tg: async with create_task_group() as tg:
tg.start_soon(conn.background_processing) tg.start_soon(conn.background_processing)
tg.start_soon(_run, conn) tg.start_soon(_run)
@stream.command() @stream.command()
@ -87,7 +87,7 @@ async def toggle(ctx: click.Context):
conn = ctx.obj["connection"] conn = ctx.obj["connection"]
ss = StreamingService(conn) ss = StreamingService(conn)
async def _run(conn): async def _run():
current_state = await ss.get_model() current_state = await ss.get_model()
active = current_state.streaming_status != "offline" active = current_state.streaming_status != "offline"
@ -102,4 +102,4 @@ async def toggle(ctx: click.Context):
async with create_task_group() as tg: async with create_task_group() as tg:
tg.start_soon(conn.background_processing) tg.start_soon(conn.background_processing)
tg.start_soon(_run, conn) tg.start_soon(_run)