From 7bede38545afb7f55c581f0caa9629af535b631c Mon Sep 17 00:00:00 2001 From: Orsiris de Jong Date: Sat, 3 Aug 2024 23:43:13 +0200 Subject: [PATCH] CLI: Improve missing repo / group responses --- npbackup/__main__.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/npbackup/__main__.py b/npbackup/__main__.py index 8d65fd1..b2fa7f0 100644 --- a/npbackup/__main__.py +++ b/npbackup/__main__.py @@ -572,17 +572,35 @@ This is free software, and you are welcome to redistribute it under certain cond for group in groups: repos = npbackup.configuration.get_repos_by_group(full_config, group) if repos is None or repos == []: - json_error_logging(False, "No corresponding repo found", level="error") + json_error_logging( + False, "No corresponding repo found", level="error" + ) sys.exit(74) elif args.repo_name: repos = [repo.strip() for repo in args.repo_name.split(",")] else: - json_error_logging(False, "No repository names or groups have been provided for group operation. Please use --repo-group or --repo-name", level="critical") + json_error_logging( + False, + "No repository names or groups have been provided for group operation. Please use --repo-group or --repo-name", + level="critical", + ) sys.exit(74) + for repo in repos: repo_config, _ = npbackup.configuration.get_repo_config(full_config, repo) - repo_config_list.append(repo_config) + if repo_config is None: + json_error_logging( + False, + f"Repo {repo} does not exist in this configuration", + level="error", + ) + repos.remove(repo) + else: + repo_config_list.append(repo_config) + if repos is None or repos == []: + json_error_logging(False, "No valid repos selected", level="error") + sys.exit(74) logger.info(f"Running group operations for repos: {', '.join(repos)}") cli_args["operation"] = "group_runner"