add --style and --no-border flags to root command

This commit is contained in:
onyx-and-iris 2025-06-22 02:39:28 +01:00
parent b0d311dad9
commit 6bcdd8391c

View File

@ -4,6 +4,7 @@ import anyio
import asyncclick as click import asyncclick as click
from pyslobs import ConnectionConfig, SlobsConnection from pyslobs import ConnectionConfig, SlobsConnection
from . import styles
from .__about__ import __version__ as version from .__about__ import __version__ as version
@ -34,11 +35,32 @@ from .__about__ import __version__ as version
required=True, required=True,
help='The token for the SLOBS server.', help='The token for the SLOBS server.',
) )
@click.option(
'-s',
'--style',
default='disabled',
envvar='SLOBS_STYLE',
show_default=True,
show_envvar=True,
help='The style to use for output.',
)
@click.option(
'-b',
'--no-border',
is_flag=True,
default=False,
envvar='SLOBS_STYLE_NO_BORDER',
show_default=True,
show_envvar=True,
help='Disable borders in the output.',
)
@click.version_option( @click.version_option(
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): async def cli(
ctx: click.Context, domain: str, port: int, token: str, style: str, no_border: bool
):
"""Command line interface for Streamlabs Desktop.""" """Command line interface for Streamlabs Desktop."""
ctx.ensure_object(dict) ctx.ensure_object(dict)
config = ConnectionConfig( config = ConnectionConfig(
@ -47,6 +69,7 @@ async def cli(ctx: click.Context, domain: str, port: int, token: str):
token=token, token=token,
) )
ctx.obj['connection'] = SlobsConnection(config) ctx.obj['connection'] = SlobsConnection(config)
ctx.obj['style'] = styles.request_style_obj(style, no_border)
def run(): def run():