From b22be2e6dc1041c794772c52b3fa8f78e433d54d Mon Sep 17 00:00:00 2001 From: deajan Date: Fri, 27 Jun 2025 13:50:19 +0200 Subject: [PATCH] CLI: Add --list-selected-repos command --- npbackup/__main__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/npbackup/__main__.py b/npbackup/__main__.py index 1b5901e..c9a2d18 100644 --- a/npbackup/__main__.py +++ b/npbackup/__main__.py @@ -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(