mirror of
https://github.com/onyx-and-iris/slobs-cli.git
synced 2025-06-27 15:20:24 +01:00
add --id option, this allows a user to optionally show the source ids
This commit is contained in:
parent
0c5bbc114f
commit
80da58bd6f
@ -12,8 +12,9 @@ def audio():
|
|||||||
|
|
||||||
|
|
||||||
@audio.command()
|
@audio.command()
|
||||||
|
@click.option("--id", is_flag=True, help="Include audio source IDs in the output.")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
async def list(ctx: click.Context):
|
async def list(ctx: click.Context, id: bool = False):
|
||||||
"""List all audio sources."""
|
"""List all audio sources."""
|
||||||
|
|
||||||
conn = ctx.obj["connection"]
|
conn = ctx.obj["connection"]
|
||||||
@ -30,8 +31,9 @@ async def list(ctx: click.Context):
|
|||||||
for source in sources:
|
for source in sources:
|
||||||
model = await source.get_model()
|
model = await source.get_model()
|
||||||
click.echo(
|
click.echo(
|
||||||
f"- {click.style(model.name, fg='blue')} (ID: {model.source_id}, "
|
f"- {click.style(model.name, fg='blue')} "
|
||||||
f"Muted: {click.style('✅', fg='green') if model.muted else click.style('❌', fg='red')})"
|
f"{f'ID: {model.source_id}, ' if id else ''}"
|
||||||
|
f"Muted: {click.style('✅', fg='green') if model.muted else click.style('❌', fg='red')}"
|
||||||
)
|
)
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ from .__about__ import __version__ as version
|
|||||||
version, "-v", "--version", message="%(prog)s version: %(version)s"
|
version, "-v", "--version", message="%(prog)s version: %(version)s"
|
||||||
)
|
)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
async def cli(ctx: click.Context, domain: str, port: int, token: str | None):
|
async def cli(ctx: click.Context, domain: str, port: int, token: str):
|
||||||
"""Command line interface for Streamlabs Desktop."""
|
"""Command line interface for Streamlabs Desktop."""
|
||||||
ctx.ensure_object(dict)
|
ctx.ensure_object(dict)
|
||||||
config = ConnectionConfig(
|
config = ConnectionConfig(
|
||||||
|
@ -12,8 +12,9 @@ def scene():
|
|||||||
|
|
||||||
|
|
||||||
@scene.command()
|
@scene.command()
|
||||||
|
@click.option("--id", is_flag=True, help="Include scene IDs in the output.")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
async def list(ctx: click.Context):
|
async def list(ctx: click.Context, id: bool = False):
|
||||||
"""List all available scenes."""
|
"""List all available scenes."""
|
||||||
|
|
||||||
conn = ctx.obj["connection"]
|
conn = ctx.obj["connection"]
|
||||||
@ -32,10 +33,14 @@ async def list(ctx: click.Context):
|
|||||||
for scene in scenes:
|
for scene in scenes:
|
||||||
if scene.id == active_scene.id:
|
if scene.id == active_scene.id:
|
||||||
click.echo(
|
click.echo(
|
||||||
f"- {click.style(scene.name, fg='green')} (ID: {scene.id}) [Active]"
|
f"- {click.style(scene.name, fg='green')} "
|
||||||
|
f"{f'(ID: {scene.id})' if id else ''} [Active]"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
click.echo(f"- {click.style(scene.name, fg='blue')} (ID: {scene.id})")
|
click.echo(
|
||||||
|
f"- {click.style(scene.name, fg='blue')} "
|
||||||
|
f"{f'(ID: {scene.id})' if id else ''}"
|
||||||
|
)
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
@ -45,8 +50,9 @@ async def list(ctx: click.Context):
|
|||||||
|
|
||||||
|
|
||||||
@scene.command()
|
@scene.command()
|
||||||
|
@click.option("--id", is_flag=True, help="Include scene IDs in the output.")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
async def current(ctx: click.Context):
|
async def current(ctx: click.Context, id: bool = False):
|
||||||
"""Show the currently active scene."""
|
"""Show the currently active scene."""
|
||||||
|
|
||||||
conn = ctx.obj["connection"]
|
conn = ctx.obj["connection"]
|
||||||
@ -55,7 +61,8 @@ async def current(ctx: click.Context):
|
|||||||
async def _run():
|
async def _run():
|
||||||
active_scene = await ss.active_scene()
|
active_scene = await ss.active_scene()
|
||||||
click.echo(
|
click.echo(
|
||||||
f"Current active scene: {click.style(active_scene.name, fg='green')} (ID: {active_scene.id})"
|
f"Current active scene: {click.style(active_scene.name, fg='green')} "
|
||||||
|
f"{f'(ID: {active_scene.id})' if id else ''}"
|
||||||
)
|
)
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
@ -65,6 +72,7 @@ async def current(ctx: click.Context):
|
|||||||
|
|
||||||
|
|
||||||
@scene.command()
|
@scene.command()
|
||||||
|
@click.option("--id", is_flag=True, help="Include scene IDs in the output.")
|
||||||
@click.argument("scene_name", type=str)
|
@click.argument("scene_name", type=str)
|
||||||
@click.option(
|
@click.option(
|
||||||
"--preview",
|
"--preview",
|
||||||
@ -72,7 +80,9 @@ async def current(ctx: click.Context):
|
|||||||
help="Switch the preview scene only.",
|
help="Switch the preview scene only.",
|
||||||
)
|
)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
async def switch(ctx: click.Context, scene_name: str, preview: bool = False):
|
async def switch(
|
||||||
|
ctx: click.Context, scene_name: str, preview: bool = False, id: bool = False
|
||||||
|
):
|
||||||
"""Switch to a scene by its name."""
|
"""Switch to a scene by its name."""
|
||||||
|
|
||||||
conn = ctx.obj["connection"]
|
conn = ctx.obj["connection"]
|
||||||
@ -89,23 +99,29 @@ async def switch(ctx: click.Context, scene_name: str, preview: bool = False):
|
|||||||
await ss.make_scene_active(scene.id)
|
await ss.make_scene_active(scene.id)
|
||||||
if preview:
|
if preview:
|
||||||
click.echo(
|
click.echo(
|
||||||
f"Switched to scene: {click.style(scene.name, fg='blue')} (ID: {scene.id}) in preview mode."
|
f"Switched to preview scene: {click.style(scene.name, fg='blue')} "
|
||||||
|
f"{f'(ID: {scene.id}).' if id else ''}"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
|
click.echo(
|
||||||
|
f"Switched to scene: {click.style(scene.name, fg='blue')} "
|
||||||
|
f"{f'(ID: {scene.id}).' if id else ''}"
|
||||||
|
)
|
||||||
await ts.execute_studio_mode_transition()
|
await ts.execute_studio_mode_transition()
|
||||||
click.echo(
|
click.echo(
|
||||||
f"Switched to scene: {click.style(scene.name, fg='blue')} (ID: {scene.id}) in active mode."
|
"Executed studio mode transition to make the scene active."
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
if preview:
|
if preview:
|
||||||
conn.close()
|
conn.close()
|
||||||
raise SlobsCliError(
|
raise SlobsCliError(
|
||||||
"Cannot switch to preview scene in non-studio mode."
|
"Cannot switch the preview scene in non-studio mode."
|
||||||
)
|
)
|
||||||
|
|
||||||
await ss.make_scene_active(scene.id)
|
await ss.make_scene_active(scene.id)
|
||||||
click.echo(
|
click.echo(
|
||||||
f"Switched to scene: {click.style(scene.name, fg='blue')} (ID: {scene.id}) in active mode."
|
f"Switched to scene: {click.style(scene.name, fg='blue')} "
|
||||||
|
f"{f'(ID: {scene.id}).' if id else ''}"
|
||||||
)
|
)
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user