CLI: Improve missing repo / group responses

This commit is contained in:
Orsiris de Jong 2024-08-03 23:43:13 +02:00
parent 69a32f3c5d
commit 7bede38545

View file

@ -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"