From 6e988bd9a953294450b63d0b547866bee6999bf7 Mon Sep 17 00:00:00 2001 From: Teemu R Date: Wed, 6 Apr 2022 02:25:47 +0200 Subject: [PATCH] Avoid discovery on --help (#335) --- kasa/cli.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kasa/cli.py b/kasa/cli.py index c9cab4b5..5c1e18f6 100755 --- a/kasa/cli.py +++ b/kasa/cli.py @@ -1,6 +1,7 @@ """python-kasa cli tool.""" import asyncio import logging +import sys from pprint import pformat as pf from typing import cast @@ -66,6 +67,12 @@ pass_dev = click.make_pass_decorator(SmartDevice) @click.pass_context async def cli(ctx, host, alias, target, debug, bulb, plug, lightstrip, strip, type): """A tool for controlling TP-Link smart home devices.""" # noqa + # no need to perform any checks if we are just displaying the help + if sys.argv[-1] == "--help": + # Context object is required to avoid crashing on sub-groups + ctx.obj = SmartDevice(None) + return + if debug: logging.basicConfig(level=logging.DEBUG) else: