From c501b48976c48988ae5fef35d2841aac525d3a88 Mon Sep 17 00:00:00 2001 From: "/)/) -- Daniel Haslinger" Date: Thu, 23 May 2024 14:01:09 +0200 Subject: [PATCH] emit proper exit codes to use in automation and scripts --- hoymiles_wifi/__main__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hoymiles_wifi/__main__.py b/hoymiles_wifi/__main__.py index d4bd6ae..453f3fb 100644 --- a/hoymiles_wifi/__main__.py +++ b/hoymiles_wifi/__main__.py @@ -5,6 +5,7 @@ from __future__ import annotations import argparse import asyncio import json +import sys from dataclasses import asdict, dataclass from google.protobuf.json_format import MessageToJson @@ -286,6 +287,8 @@ def print_invalid_command(command: str) -> None: """Print an invalid command message.""" print(f"Invalid command: {command}") # noqa: T201 + sys.exit(1) + async def main() -> None: @@ -366,6 +369,7 @@ async def main() -> None: f"No response or unable to retrieve response for " f"{args.command.replace('_', ' ')}", ) + sys.exit(2) def run_main() -> None: