34 lines
1021 B
Python
34 lines
1021 B
Python
|
|
import os
|
||
|
|
import configparser
|
||
|
|
from rich import print
|
||
|
|
from rich.table import Table
|
||
|
|
|
||
|
|
|
||
|
|
def list_cmd(args):
|
||
|
|
ground_libs_folder = os.getenv("GROUND_LIBS") or "/usr/lib/ground/"
|
||
|
|
folders = os.listdir(ground_libs_folder)
|
||
|
|
|
||
|
|
table = Table("Name", "Version", "Description", title="Installed")
|
||
|
|
config_parser = configparser.ConfigParser()
|
||
|
|
|
||
|
|
for folder in folders:
|
||
|
|
full_path = os.path.join(ground_libs_folder, folder)
|
||
|
|
|
||
|
|
# skip anything that isnt a folder
|
||
|
|
if not os.path.isdir(full_path):
|
||
|
|
continue
|
||
|
|
|
||
|
|
# read the mineral.ini file to figure out the version and description
|
||
|
|
ini_path = os.path.join(full_path, "mineral.ini")
|
||
|
|
if not os.path.isfile(ini_path):
|
||
|
|
continue
|
||
|
|
|
||
|
|
config_parser.read(ini_path)
|
||
|
|
|
||
|
|
table.add_row(
|
||
|
|
f"[b]{folder}",
|
||
|
|
f"[blue]{config_parser.get('package', 'version')}",
|
||
|
|
config_parser.get("package", "description"),
|
||
|
|
)
|
||
|
|
|
||
|
|
print(table)
|