|
|
|
@ -19,6 +19,7 @@ from argparse import ArgumentParser |
|
|
|
from pathlib import Path |
|
|
|
|
|
|
|
from bsv import __version__ |
|
|
|
from bsv.cli import get_console |
|
|
|
from bsv.command import command |
|
|
|
from bsv.repository import Repository |
|
|
|
|
|
|
|
@ -33,27 +34,29 @@ def init_parser(parser: ArgumentParser): |
|
|
|
) |
|
|
|
|
|
|
|
@command(init_parser) |
|
|
|
def info(repository_path: Path | None, verbosity: int=0) -> int: |
|
|
|
def info(config_path: Path, verbosity: int=0) -> int: |
|
|
|
"""Print informations about bsv: config file used, known repository, file mapping... |
|
|
|
""" |
|
|
|
|
|
|
|
print(f"bsv v{__version__}") |
|
|
|
print = get_console().print |
|
|
|
|
|
|
|
if repository_path is None: |
|
|
|
print("Repository path not found. Bsv is likely not setup on this device.") |
|
|
|
print(f"bsv [green]v{__version__}") |
|
|
|
|
|
|
|
if not config_path.exists(): |
|
|
|
print("bsv configuration not found. Bsv is likely not setup on this device.", style="red") |
|
|
|
return 0 |
|
|
|
else: |
|
|
|
print(f"Repository path: {repository_path}") |
|
|
|
|
|
|
|
repo = Repository(repository_path) |
|
|
|
repo = Repository(config_path) |
|
|
|
|
|
|
|
print(f"Repository name: {repo.name}") |
|
|
|
print(f"[blue]Config path: [bold yellow]{repo.config_path}") |
|
|
|
print(f"[blue]Device name: [bold yellow]{repo.device_name}") |
|
|
|
print(f"[blue]Local repository: [bold yellow]{repo._local_repository_path}") |
|
|
|
|
|
|
|
if repo.path_map: |
|
|
|
print("Path map: (bsv path <-> filesystem path)") |
|
|
|
for pair in sorted(repo.path_map): |
|
|
|
print("[blue]Path map:[/blue] (bsv path <-> filesystem path)") |
|
|
|
if repo.path_map.pairs: |
|
|
|
for pair in sorted(repo.path_map.pairs): |
|
|
|
print(f" {pair.bsv} <-> {pair.fs}") |
|
|
|
else: |
|
|
|
print("Path map is empty.") |
|
|
|
print(" [bold yellow]No path mapped.") |
|
|
|
|
|
|
|
return 0 |
|
|
|
|