From b21781109659d6a9194db478e674977b6a2d80ed Mon Sep 17 00:00:00 2001 From: Teemu R Date: Thu, 23 May 2024 20:35:41 +0200 Subject: [PATCH] Do not show a zero error code when cli exits from showing help (#935) asyncclick raises a custom runtime exception when exiting help. This suppresses reporting it. --- kasa/cli.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kasa/cli.py b/kasa/cli.py index 235387bc..f56aaccd 100755 --- a/kasa/cli.py +++ b/kasa/cli.py @@ -111,6 +111,10 @@ def CatchAllExceptions(cls): def _handle_exception(debug, exc): if isinstance(exc, click.ClickException): raise + # Handle exit request from click. + if isinstance(exc, click.exceptions.Exit): + sys.exit(exc.exit_code) + echo(f"Raised error: {exc}") if debug: raise