diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d4f441b..65605ef 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -108,3 +108,6 @@ jobs: - name: CLI - Echoing help run: geotribu --help + + - name: CLI - Search content + run: geotribu search-content --no-prompt -n 10 "python +osm" diff --git a/geotribu_cli/__about__.py b/geotribu_cli/__about__.py index e623aae..e42dc60 100644 --- a/geotribu_cli/__about__.py +++ b/geotribu_cli/__about__.py @@ -38,7 +38,7 @@ __uri__ = __uri_repository__ -__version__ = "0.34.0" +__version__ = "0.34.1" __version_info__ = tuple( [ int(num) if num.isdigit() else num diff --git a/geotribu_cli/comments/comments_open.py b/geotribu_cli/comments/comments_open.py index b9b7cd8..ea42561 100644 --- a/geotribu_cli/comments/comments_open.py +++ b/geotribu_cli/comments/comments_open.py @@ -7,16 +7,14 @@ # standard library import argparse import logging -import sys from os import getenv -# 3rd party -from rich import print - -# package from geotribu_cli.cli_results_rich_formatters import format_output_result_comments from geotribu_cli.comments.comments_toolbelt import find_comment_by_id from geotribu_cli.comments.mdl_comment import Comment + +# package +from geotribu_cli.console import console from geotribu_cli.constants import GeotribuDefaults from geotribu_cli.utils.start_uri import open_uri @@ -132,21 +130,20 @@ def run(args: argparse.Namespace): logger.error( f"Une erreur a empêché la récupération des commentaires. Trace: {err}" ) - sys.exit(1) # si le commentaire n'a pas été trouvé - if not isinstance(comment_obj, Comment): - print( + if isinstance(comment_obj, Comment): + if args.open_with == "shell": + console.print( + format_output_result_comments( + results=[comment_obj], format_type=args.format_output, count=1 + ) + ) + else: + open_uri(in_filepath=comment_obj.url_to_comment) + + else: + console.print( f":person_shrugging: Le commentaire {args.comment_id} n'a pu être trouvé. " "Est-il publié et validé ?" ) - sys.exit(0) - - if args.open_with == "shell": - print( - format_output_result_comments( - results=[comment_obj], format_type=args.format_output, count=1 - ) - ) - else: - open_uri(in_filepath=comment_obj.url_to_comment) diff --git a/tests/test_cli.py b/tests/test_cli.py index 3c1f0c6..2a97605 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -86,11 +86,12 @@ def test_cli_run_comments_open_specific(capsys): "comments", "open", "--page-size", - "25", + "100", "--comment-id", "15", "--expiration-rotating-hours", "0", + "-vv", ] )