scene list and audio list now print tables

patch bump
This commit is contained in:
onyx-and-iris 2025-06-12 18:49:54 +01:00
parent 2a18b94b11
commit a1a22d0d00
5 changed files with 53 additions and 19 deletions

View File

@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
# [0.8.3] - 2025-06-12
# [0.8.4] - 2025-06-12
### Added
@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- scene list now shows which scene is the current active scene.
- audio list now shows mute states.
- scene list and audio list commands now print as tables
- --id option added to scene and audio commands to show the source ID in the output
- by default this is no longer displayed

13
pdm.lock generated
View File

@ -5,7 +5,7 @@
groups = ["default", "dev"]
strategy = ["inherit_metadata"]
lock_version = "4.5.0"
content_hash = "sha256:87714b892affeadd7dba57d9430f0af3dc46f50cc9d095942367e4fca103f61e"
content_hash = "sha256:e24474fa487e6f512b9c1f5a97aaabf58ed6164fb084f12e954ec59f1c4f8545"
[[metadata.targets]]
requires_python = ">=3.11"
@ -249,6 +249,17 @@ files = [
{file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"},
]
[[package]]
name = "terminaltables3"
version = "4.0.0"
requires_python = ">=3.8"
summary = "Generate simple tables in terminals from a nested list of strings. Fork of terminaltables."
groups = ["default"]
files = [
{file = "terminaltables3-4.0.0-py3-none-any.whl", hash = "sha256:93b4c722f35400a7869cd630e2bbab616b129d1c47c628765c7f47baab2ca270"},
{file = "terminaltables3-4.0.0.tar.gz", hash = "sha256:4e3eefe209aa89005a0a34d1525739424569729ee29b5e64a8dd51c5ebdab77f"},
]
[[package]]
name = "tox"
version = "4.26.0"

View File

@ -2,7 +2,7 @@
name = "slobs-cli"
description = "A command line application for Streamlabs Desktop"
authors = [{ name = "onyx-and-iris", email = "code@onyxandiris.online" }]
dependencies = ["pyslobs>=2.0.5", "asyncclick>=8.1.8"]
dependencies = ["pyslobs>=2.0.5", "asyncclick>=8.1.8", "terminaltables3>=4.0.0"]
requires-python = ">=3.11"
readme = "README.md"
license = { text = "MIT" }
@ -36,6 +36,6 @@ post_test.cmd = "python tests/teardown.py"
dev = [
"tox-pdm>=0.7.2",
"pytest>=8.4.0",
"virtualenv-pyenv>=0.5.0",
"pytest-randomly>=3.16.0",
"virtualenv-pyenv>=0.5.0",
]

View File

@ -1,6 +1,7 @@
import asyncclick as click
from anyio import create_task_group
from pyslobs import AudioService
from terminaltables3 import AsciiTable
from .cli import cli
from .errors import SlobsCliError
@ -27,14 +28,25 @@ async def list(ctx: click.Context, id: bool = False):
conn.close()
return
click.echo("Available audio sources:")
table_data = [["Audio Name", "ID", "Muted"] if id else ["Name", "Muted"]]
for source in sources:
model = await source.get_model()
click.echo(
f"- {click.style(model.name, fg='blue')} "
f"{f'ID: {model.source_id}, ' if id else ''}"
f"Muted: {click.style('', fg='green') if model.muted else click.style('', fg='red')}"
)
to_append = [f"{click.style(model.name, fg='blue')}"]
if id:
to_append.append(f"{model.source_id}")
to_append.append("" if model.muted else "")
table_data.append(to_append)
table = AsciiTable(table_data)
table.justify_columns = {
0: "left",
1: "left" if id else "center",
2: "center" if id else None,
}
click.echo(table.table)
conn.close()
async with create_task_group() as tg:

View File

@ -1,6 +1,7 @@
import asyncclick as click
from anyio import create_task_group
from pyslobs import ScenesService, TransitionsService
from terminaltables3 import AsciiTable
from .cli import cli
from .errors import SlobsCliError
@ -29,18 +30,27 @@ async def list(ctx: click.Context, id: bool = False):
active_scene = await ss.active_scene()
click.echo("Available scenes:")
table_data = [
["Scene Name", "ID", "Active"] if id else ["Scene Name", "Active"]
]
for scene in scenes:
if scene.id == active_scene.id:
click.echo(
f"- {click.style(scene.name, fg='green')} "
f"{f'(ID: {scene.id})' if id else ''} [Active]"
)
to_append = [f"{click.style(scene.name, fg='green')}"]
else:
click.echo(
f"- {click.style(scene.name, fg='blue')} "
f"{f'(ID: {scene.id})' if id else ''}"
)
to_append = [f"{click.style(scene.name, fg='blue')}"]
if id:
to_append.append(f"{scene.id}")
to_append.append("" if scene.id == active_scene.id else "")
table_data.append(to_append)
table = AsciiTable(table_data)
table.justify_columns = {
0: "left",
1: "left" if id else "center",
2: "center" if id else None,
}
click.echo(table.table)
conn.close()