From b664d42be21e23b93d208f06d7da173b9dcfad7c Mon Sep 17 00:00:00 2001 From: Teemu Rytilahti Date: Tue, 30 Apr 2024 01:33:01 +0200 Subject: [PATCH] Fix --help on subcommands Pass a dummy object as context object as it will not be used by --help anyway. Also, allow defining --help anywhere in the argv, not just in the last place. --- kasa/cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kasa/cli.py b/kasa/cli.py index d8191a8f0..b55fecebf 100755 --- a/kasa/cli.py +++ b/kasa/cli.py @@ -306,9 +306,9 @@ async def cli( ): """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": + if "--help" in sys.argv: # Context object is required to avoid crashing on sub-groups - ctx.obj = Device(None) + ctx.obj = object() return # If JSON output is requested, disable echo