# bsv - Backup, Synchronization, Versioning # Copyright (C) 2023 Simon Boyé # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . from __future__ import annotations 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 def init_parser(parser: ArgumentParser): parser.add_argument( "--verbose", "-v", action = "count", default = 0, help = "Verbosity level. Specify several times to increase verbosity.", dest = "verbosity", ) @command(init_parser) def info(config_path: Path, verbosity: int=0) -> int: """Print informations about bsv: config file used, known repository, file mapping... """ print = get_console().print 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 repo = Repository(config_path) 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}") 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(" [bold yellow]No path mapped.") return 0