emit proper exit codes to use in automation and scripts

This commit is contained in:
/)/) -- Daniel Haslinger 2024-05-23 14:01:09 +02:00 committed by GitHub
parent 57439fc14f
commit c501b48976
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,6 +5,7 @@ from __future__ import annotations
import argparse import argparse
import asyncio import asyncio
import json import json
import sys
from dataclasses import asdict, dataclass from dataclasses import asdict, dataclass
from google.protobuf.json_format import MessageToJson from google.protobuf.json_format import MessageToJson
@ -286,6 +287,8 @@ def print_invalid_command(command: str) -> None:
"""Print an invalid command message.""" """Print an invalid command message."""
print(f"Invalid command: {command}") # noqa: T201 print(f"Invalid command: {command}") # noqa: T201
sys.exit(1)
async def main() -> None: async def main() -> None:
@ -366,6 +369,7 @@ async def main() -> None:
f"No response or unable to retrieve response for " f"No response or unable to retrieve response for "
f"{args.command.replace('_', ' ')}", f"{args.command.replace('_', ' ')}",
) )
sys.exit(2)
def run_main() -> None: def run_main() -> None: