you can search rocks now

This commit is contained in:
2026-06-20 17:24:12 +10:00
parent dbd879c149
commit fd8aa149ca
4 changed files with 37 additions and 2 deletions

26
neb/src/search.py Normal file
View File

@@ -0,0 +1,26 @@
from .util import get_package_index
from .console import console
from rich.table import Table
from rich.box import ROUNDED
def search(args):
index = get_package_index()
matching_keys = [key for key in index if args.query in key]
if args.limit >= 0:
matching_keys = matching_keys[:args.limit]
if len(matching_keys) == 0:
console.print("Search returned no results.")
return
table = Table("Rock", "Description", header_style="bold blue", box=ROUNDED, title="Search Results")
for i, key in enumerate(matching_keys):
rock = index[key]
table.add_row(f"[b]{key}[/]", rock.get("description", "<empty>"))
console.print(table)