From 1e923dacb9b1f926e9755c00d3d59508294ddc6b Mon Sep 17 00:00:00 2001 From: Evgenij Titarenko Date: Mon, 9 Jan 2023 23:47:22 +0300 Subject: [PATCH] Initial search implementation --- mc-get.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/mc-get.py b/mc-get.py index a7c7da5..b177a41 100755 --- a/mc-get.py +++ b/mc-get.py @@ -4,6 +4,7 @@ import api import mcfs import npyscreen import os +from colorama import Fore, Style def validate(): pass @@ -54,8 +55,17 @@ def install(projects:list): mcfs.install(filename, subdir) -def search(): - pass +def search(query:list): + + results = api.search(query=' '.join(query)) + + + for result in results.hits: + print(Fore.GREEN, end="") + print(result.get("slug", "error"), end="") + print(Style.RESET_ALL, end="") + print(f' [{result.get("project_type", "error")}] ', end="") + print(f' : {Fore.GREEN}{result.get("title", "error")}{Style.RESET_ALL} --- {result.get("description", "error")}') def clean(): if mcfs.is_path_exist(mcfs.cache_dir): @@ -78,6 +88,7 @@ if __name__ == "__main__": parser_install.add_argument("projects", nargs="+") parser_search = subparsers.add_parser("search", help="Find a mod or a resource") + parser_search.add_argument("query", nargs="+") parser_validate = subparsers.add_parser("validate", help="Validate the installation")