mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2025-10-23 15:11:08 +00:00
fix(env): 🐛 Improve handling of directory paths in info command
* Enhanced the `info` command to support both single `Path` objects and lists of `Path` objects. * For lists, each path is now displayed on a separate line, improving readability. * Maintained original logic for single `Path` objects to ensure consistent behavior.
This commit is contained in:
@@ -98,12 +98,21 @@ def info() -> None:
|
|||||||
for name in sorted(dir(config.directories)):
|
for name in sorted(dir(config.directories)):
|
||||||
if name.startswith("__") or name == "app_dirs":
|
if name.startswith("__") or name == "app_dirs":
|
||||||
continue
|
continue
|
||||||
path = getattr(config.directories, name).resolve()
|
attr_value = getattr(config.directories, name)
|
||||||
for var, var_path in path_vars.items():
|
|
||||||
if path.is_relative_to(var_path):
|
# Handle both single Path objects and lists of Path objects
|
||||||
path = rf"%{var}%\{path.relative_to(var_path)}"
|
if isinstance(attr_value, list):
|
||||||
break
|
# For lists, show each path on a separate line
|
||||||
table.add_row(name.title(), str(path))
|
paths_str = "\n".join(str(path.resolve()) for path in attr_value)
|
||||||
|
table.add_row(name.title(), paths_str)
|
||||||
|
else:
|
||||||
|
# For single Path objects, use the original logic
|
||||||
|
path = attr_value.resolve()
|
||||||
|
for var, var_path in path_vars.items():
|
||||||
|
if path.is_relative_to(var_path):
|
||||||
|
path = rf"%{var}%\{path.relative_to(var_path)}"
|
||||||
|
break
|
||||||
|
table.add_row(name.title(), str(path))
|
||||||
|
|
||||||
console.print(Padding(table, (1, 5)))
|
console.print(Padding(table, (1, 5)))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user