From 959b62222e8bcbffe396a68720cc6cc57947a27b Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Fri, 19 Apr 2024 19:26:47 +0100 Subject: [PATCH] fix(env): List all directories as table in info --- devine/commands/env.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/devine/commands/env.py b/devine/commands/env.py index ce57dbe..0258045 100644 --- a/devine/commands/env.py +++ b/devine/commands/env.py @@ -3,8 +3,11 @@ import shutil from typing import Optional import click +from rich.padding import Padding +from rich.table import Table from devine.core.config import config, config_path +from devine.core.console import console from devine.core.constants import context_settings from devine.core.services import Services @@ -18,13 +21,26 @@ def env() -> None: def info() -> None: """Displays information about the current environment.""" log = logging.getLogger("env") - log.info(f"[Config] : {config_path or '--'}") - log.info(f"[Cookies] : {config.directories.cookies}") - log.info(f"[WVDs] : {config.directories.wvds}") - log.info(f"[Cache] : {config.directories.cache}") - log.info(f"[Logs] : {config.directories.logs}") - log.info(f"[Temp Files] : {config.directories.temp}") - log.info(f"[Downloads] : {config.directories.downloads}") + + if config_path: + log.info(f"Config loaded from {config_path}") + else: + log.info("No config file found...") + + table = Table(title="Directories", expand=True) + table.add_column("Name", no_wrap=True) + table.add_column("Path") + + for name in sorted(dir(config.directories)): + if name.startswith("__") or name == "app_dirs": + continue + path = getattr(config.directories, name).resolve() + table.add_row(name.title(), str(path)) + + console.print(Padding( + table, + (1, 5) + )) @env.group(name="clear", short_help="Clear an environment directory.", context_settings=context_settings)