From 4c127ac5dab299e91a56fa2d675b771b45a79cdd Mon Sep 17 00:00:00 2001 From: Braden Mars Date: Mon, 28 Nov 2022 04:18:17 -0600 Subject: [PATCH] feat(cli): improve stub search output. --- micropy/cli.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/micropy/cli.py b/micropy/cli.py index 16128f1d..62aaf9b9 100644 --- a/micropy/cli.py +++ b/micropy/cli.py @@ -1,8 +1,11 @@ #!/usr/bin/env python """MicropyCli Console Entrypoint.""" +from __future__ import annotations + import sys from pathlib import Path +from typing import TYPE_CHECKING import click import micropy.exceptions as exc @@ -12,6 +15,9 @@ from micropy.project import Project, modules from questionary import Choice +if TYPE_CHECKING: + from stubs import StubManager + pass_mpy = click.make_pass_decorator(main.MicroPy, ensure=True) @@ -225,13 +231,16 @@ def add(mpy, stub_name, force=False): @stubs.command() @click.argument("query", required=True) @pass_mpy -def search(mpy, query): +def search(mpy: main.MicroPy, query): """Search available Stubs.""" mpy.log.title(f"Searching Stub Repositories...") - results = mpy.stubs.search_remote(query) + stubs: StubManager = mpy.stubs # noqa + results = stubs.search_remote(query) + results = sorted(results, key=lambda pkg: pkg[0].name) mpy.log.title(f"Results for $[{query}]:") for pkg, installed in results: - name = f"{pkg} $B[(Installed)]" if installed else pkg + name = f"$W[{pkg.repo_name}]/{pkg.versioned_name}" + name = f"{pkg.absolute_versioned_name} $B[(Installed)]" if installed else name mpy.log.info(name)