CLI: Add --list-selected-repos command

This commit is contained in:
deajan 2025-06-27 13:50:19 +02:00
parent 1dd77265b0
commit b22be2e6dc

View file

@ -83,6 +83,12 @@ This is free software, and you are welcome to redistribute it under certain cond
required=False,
help="Comme separated list of groups to work with. Can accept special name '__all__' to work with all repositories.",
)
parser.add_argument(
"--list-selected-repos",
action="store_true",
default=False,
help="List selected repositories and groups when using --repo-name and/or --repo-group.",
)
parser.add_argument("-b", "--backup", action="store_true", help="Run a backup")
parser.add_argument(
"-f",
@ -445,6 +451,13 @@ This is free software, and you are welcome to redistribute it under certain cond
# Cheap duplicate filter
repos_and_group_repos = list(set(repos_and_group_repos))
if args.list_selected_repos:
if _JSON:
print(json.dumps({"result": True, "repositories": repos_and_group_repos}))
else:
logger.info(f"Repository list:\n{repos_and_group_repos}")
sys.exit(0)
# Single repo usage
if len(repos_and_group_repos) == 1:
repo_config, _ = npbackup.configuration.get_repo_config(