From 3242a866e32270fcf5278d131be1161a446f9a95 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Tue, 10 Jun 2025 12:51:04 +0100 Subject: [PATCH] implement slobs connection flags/envvars add slobs connection to context patch bump --- pyproject.toml | 2 +- src/slobs_cli/cli.py | 45 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/slobs_cli/cli.py diff --git a/pyproject.toml b/pyproject.toml index 7502a93..6d1a4d5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "slobs-cli" -version = "0.1.0" +version = "0.1.1" 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"] diff --git a/src/slobs_cli/cli.py b/src/slobs_cli/cli.py new file mode 100644 index 0000000..dca3bfc --- /dev/null +++ b/src/slobs_cli/cli.py @@ -0,0 +1,45 @@ +import anyio +import asyncclick as click +from pyslobs import ConnectionConfig, SlobsConnection + + +@click.group() +@click.option( + "--domain", + default="localhost", + show_default=True, + show_envvar=True, + help="The domain of the SLOBS server.", + envvar="SLOBS_DOMAIN", +) +@click.option( + "--port", + default=59650, + show_default=True, + show_envvar=True, + help="The port of the SLOBS server.", + envvar="SLOBS_PORT", +) +@click.option( + "--token", + help="The token for the SLOBS server.", + envvar="SLOBS_TOKEN", + show_envvar=True, +) +@click.pass_context +async def cli(ctx: click.Context, domain: str, port: int, token: str | None): + """ + Command line interface for SLOBS. + """ + ctx.ensure_object(dict) + config = ConnectionConfig( + domain=domain, + port=port, + token=token, + ) + ctx.obj["connection"] = SlobsConnection(config) + + +def run(): + """Run the CLI application.""" + anyio.run(cli.main)