mirror of
https://github.com/onyx-and-iris/slobs-cli.git
synced 2025-08-07 20:21:55 +00:00
53 lines
1.1 KiB
Python
53 lines
1.1 KiB
Python
import anyio
|
|
import asyncclick as click
|
|
from pyslobs import ConnectionConfig, SlobsConnection
|
|
|
|
from .__about__ import __version__ as version
|
|
|
|
|
|
@click.group()
|
|
@click.option(
|
|
"-d",
|
|
"--domain",
|
|
default="127.0.0.1",
|
|
show_default=True,
|
|
show_envvar=True,
|
|
help="The domain of the SLOBS server.",
|
|
envvar="SLOBS_DOMAIN",
|
|
)
|
|
@click.option(
|
|
"-p",
|
|
"--port",
|
|
default=59650,
|
|
show_default=True,
|
|
show_envvar=True,
|
|
help="The port of the SLOBS server.",
|
|
envvar="SLOBS_PORT",
|
|
)
|
|
@click.option(
|
|
"-t",
|
|
"--token",
|
|
help="The token for the SLOBS server.",
|
|
envvar="SLOBS_TOKEN",
|
|
show_envvar=True,
|
|
required=True,
|
|
)
|
|
@click.version_option(
|
|
version, "-v", "--version", message="%(prog)s version: %(version)s"
|
|
)
|
|
@click.pass_context
|
|
async def cli(ctx: click.Context, domain: str, port: int, token: str | None):
|
|
"""Command line interface for Streamlabs Desktop."""
|
|
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)
|