fix(ocpp-server): ensure the CLI options help is not truncated
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 27 Jun 2024 23:08:41 +0000 (01:08 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 27 Jun 2024 23:08:41 +0000 (01:08 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
tests/ocpp-server/server.py
tests/ocpp-server/timer.py

index fdef6bed7b0ad0fde5bd48bfcea3a689391c5e52..483c750f20dd79fa56c0a15d3a8dbb0fb841459a 100644 (file)
@@ -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()
 
index aca740454fd3cbc6de02b58193d0ec165b7b2b5f..e81d05b951146db20777227aa5fc98b01e7e68b2 100644 (file)
@@ -12,7 +12,8 @@ class Timer:
         callback_args=(),
         callback_kwargs=None,
     ):
-        """An asynchronous Timer object.
+        """
+        An asynchronous Timer object.
 
         Parameters
         ----------