Initial search implementation

This commit is contained in:
Евгений Титаренко 2023-01-09 23:47:22 +03:00
parent 17d02bd27c
commit 1e923dacb9

View file

@ -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")