From 3291c1c0cc2bc9a8f6716cdc201b5b0680c376fb Mon Sep 17 00:00:00 2001 From: bbhtt Date: Mon, 12 Feb 2024 07:34:59 +0530 Subject: [PATCH] Make help message a key-value pair in results dict --- flatpak_builder_lint/cli.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/flatpak_builder_lint/cli.py b/flatpak_builder_lint/cli.py index c74bfb02..f45dc7b8 100644 --- a/flatpak_builder_lint/cli.py +++ b/flatpak_builder_lint/cli.py @@ -5,7 +5,7 @@ import os import pkgutil import sys -from typing import Optional, Union +from typing import Dict, List, Optional, Union import requests import sentry_sdk @@ -69,7 +69,7 @@ def run_checks( if callable(check_method): check_method(check_method_arg) - results = {} + results: Dict[str, Union[str, List[Optional[str]]]] = {} if errors := checks.Check.errors: results["errors"] = list(errors) if warnings := checks.Check.warnings: @@ -106,6 +106,12 @@ def run_checks( if not results["warnings"]: results.pop("warnings") + help = ("Please consult the documentation at " + "https://docs.flathub.org/docs/for-app-authors/linter") + + if "errors" in results or "warnings" in results: + results["message"] = help + return results @@ -163,11 +169,6 @@ def main() -> int: output = json.dumps(results, indent=4) print(output) - if len(output) != 0: - print( - "\nPlease consult the documentation at" - " https://docs.flathub.org/docs/for-app-authors/linter" - ) sys.exit(exit_code)