From 72f424e9b8fa37a6148ac0ee867959f3854c9c58 Mon Sep 17 00:00:00 2001 From: Nova <126072875+nova-r@users.noreply.github.com> Date: Mon, 13 Mar 2023 23:12:20 +0100 Subject: [PATCH] add cli websocket parameter (#27) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mæve Rey <42996147M-rey@users.noreply.github.com> --- fediplug/buttplugio.py | 4 ++-- fediplug/cli.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/fediplug/buttplugio.py b/fediplug/buttplugio.py index 9410d24..4820998 100644 --- a/fediplug/buttplugio.py +++ b/fediplug/buttplugio.py @@ -11,10 +11,10 @@ from fediplug.cli import options from typing import Tuple -async def connect_plug_client() -> Client: +async def connect_plug_client(websocket_url: str = "127.0.0.1:12345") -> Client: """create Client object and connect plug client to Intiface Central or similar""" plug_client = Client("fediplug", ProtocolSpec.v3) - connector = WebsocketConnector("ws://127.0.0.1:12345", logger=plug_client.logger) + connector = WebsocketConnector(f"ws://{websocket_url}", logger=plug_client.logger) try: await plug_client.connect(connector) diff --git a/fediplug/cli.py b/fediplug/cli.py index 9935f27..b68cff5 100644 --- a/fediplug/cli.py +++ b/fediplug/cli.py @@ -88,13 +88,16 @@ def login(instance: str) -> None: @cli.command() +@click.option("-w", "--websocket", help="Pass an alternative websocket.") @click.argument("instance") @click.argument("users", nargs=-1) -def stream(instance: str, users: Tuple[str]): +def stream(instance: str, users: Tuple[str], websocket: str): """Control buttplug.io device from your timeline.""" event_loop = asyncio.get_event_loop() - plug_client = event_loop.run_until_complete(buttplugio.connect_plug_client()) + plug_client = event_loop.run_until_complete( + buttplugio.connect_plug_client(websocket) + ) plug_client = event_loop.run_until_complete(buttplugio.scan_devices(plug_client)) client_id, client_secret = get_client_credentials(instance)