Skip to content

Commit

Permalink
feat(cli): format repo as title in stubs search output.
Browse files Browse the repository at this point in the history
Signed-off-by: Braden Mars <bradenmars@bradenmars.me>
  • Loading branch information
BradenM committed Dec 11, 2022
1 parent b9de35a commit eaf0543
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions micropy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,15 @@ def search(mpy: main.MicroPy, query):
results = stubs.search_remote(query)
results = sorted(results, key=lambda pkg: pkg[0].name)
mpy.log.title(f"Results for $[{query}]:")
max_name = max(len(n[0].repo_name) for n in results)
for pkg, installed in results:
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)
pad = max_name - len(pkg.repo_name) + 2
pad = pad if (pad % 2 == 0) else pad + 1
spacer = "{:>{pad}}".format(f"::", pad=pad)
repo_logger = Log.add_logger(f"{pkg.repo_name} {spacer}", "bright_white")
name = "{:>{pad}}".format(pkg.versioned_name, pad=pad)
name = f"{name} $B[(Installed)]" if installed else name
repo_logger.info(name)


@stubs.command()
Expand Down

0 comments on commit eaf0543

Please sign in to comment.