From ba56e7c9946964b7c28adb72cd54eeb805194f25 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 28 Jun 2024 01:08:41 +0200 Subject: [PATCH] fix(ocpp-server): ensure the CLI options help is not truncated MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- tests/ocpp-server/server.py | 8 +++----- tests/ocpp-server/timer.py | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tests/ocpp-server/server.py b/tests/ocpp-server/server.py index fdef6bed..483c750f 100644 --- a/tests/ocpp-server/server.py +++ b/tests/ocpp-server/server.py @@ -208,11 +208,8 @@ def check_positive_number(value: Optional[float]): # Main function to start the WebSocket server. async def main(): parser = argparse.ArgumentParser(description="OCPP2 Server") - parser.add_argument("-c", "--command", type=Action, help="OCPP2 command name") - parsed_args, _ = parser.parse_known_args() - group = parser.add_mutually_exclusive_group( - required=parsed_args.command is not None - ) + parser.add_argument("-c", "--command", type=Action, help="command name") + group = parser.add_mutually_exclusive_group() group.add_argument( "-d", "--delay", @@ -225,6 +222,7 @@ async def main(): type=check_positive_number, help="period in seconds", ) + group.required = parser.parse_known_args()[0].command is not None args = parser.parse_args() diff --git a/tests/ocpp-server/timer.py b/tests/ocpp-server/timer.py index aca74045..e81d05b9 100644 --- a/tests/ocpp-server/timer.py +++ b/tests/ocpp-server/timer.py @@ -12,7 +12,8 @@ class Timer: callback_args=(), callback_kwargs=None, ): - """An asynchronous Timer object. + """ + An asynchronous Timer object. Parameters ---------- -- 2.34.1