add cli websocket parameter (#27)

Co-authored-by: Mæve Rey <42996147M-rey@users.noreply.github.com>
This commit is contained in:
Nova 2023-03-13 23:12:20 +01:00 committed by GitHub
parent d2910785ed
commit 72f424e9b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -11,10 +11,10 @@ from fediplug.cli import options
from typing import Tuple 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""" """create Client object and connect plug client to Intiface Central or similar"""
plug_client = Client("fediplug", ProtocolSpec.v3) 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: try:
await plug_client.connect(connector) await plug_client.connect(connector)

View file

@ -88,13 +88,16 @@ def login(instance: str) -> None:
@cli.command() @cli.command()
@click.option("-w", "--websocket", help="Pass an alternative websocket.")
@click.argument("instance") @click.argument("instance")
@click.argument("users", nargs=-1) @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.""" """Control buttplug.io device from your timeline."""
event_loop = asyncio.get_event_loop() 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)) plug_client = event_loop.run_until_complete(buttplugio.scan_devices(plug_client))
client_id, client_secret = get_client_credentials(instance) client_id, client_secret = get_client_credentials(instance)