From 3ca6fad9e1bfd1923ee14e8af6d37b286993ba2c Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 26 Mar 2023 22:24:21 +0300 Subject: [PATCH] Updated for binary repo option --- slpkg/binaries/queries.py | 1 + slpkg/main.py | 14 +++++++++++++- slpkg/views/cli_menu.py | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/slpkg/binaries/queries.py b/slpkg/binaries/queries.py index 2d5a3dc9..3e5cd9e8 100644 --- a/slpkg/binaries/queries.py +++ b/slpkg/binaries/queries.py @@ -17,6 +17,7 @@ class BinQueries(Configs): self.repo: str = repo self.session = Session self.repos = Repositories() + self.bin_repo: list = [] if self.repo is None or self.repo == '*': self.bin_repo: list = self.repos.enabled_repositories diff --git a/slpkg/main.py b/slpkg/main.py index cf6bd3cb..bee467a0 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -79,7 +79,7 @@ class Argparse(Configs): self.flag_short_parallel: str = '-P' self.flag_binary: str = '--binary' self.flag_short_binary: str = '-B' - self.flag_bin_repository: str = '--repository=' + self.flag_bin_repository: str = '--bin-repo=' self.flag_short_bin_repository: str = '-O=' self.flag_directory: str = '--directory=' self.flag_short_directory: str = '-z=' @@ -279,6 +279,18 @@ class Argparse(Configs): self.check = Check(self.flags) self.check.is_blacklist(self.args[1:]) + self.check_for_repositories() + + def check_for_repositories(self): + """ Checks combination for binaries use repositories only and if repository exists. """ + if (self.utils.is_option([self.flag_bin_repository, self.flag_short_bin_repository], self.flags) and not + self.utils.is_option([self.flag_binary, self.flag_short_binary], self.flags)): + print(f"{self.prog_name}: invalid combination '{', '.join(self.flags)}'") + self.usage.help_minimal() + + if self.binary_repo and self.binary_repo not in self.repos.binaries_repositories_dict.keys(): + print(f"{self.prog_name}: invalid binary repository '{self.binary_repo}'") + self.usage.help_minimal() def invalid_options(self) -> None: """ Checks for invalid options. """ diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index e0f8eaf9..cdc08ad7 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -40,7 +40,7 @@ class Usage(Configs): f' slpkg [{self.yellow}OPTIONS{self.endc}] [-y, --yes, -j, --jobs, -o, --resolve-off, -r, --reinstall]\n' f' slpkg [{self.yellow}OPTIONS{self.endc}] [-k, --skip-installed, -E, --full-reverse, -S, --search]\n' f' slpkg [{self.yellow}OPTIONS{self.endc}] [-n, --no-silent, -p, --pkg-version, -G, --generate-only]\n' - f' slpkg [{self.yellow}OPTIONS{self.endc}] [-P, --parallel, -B, --binary, -O, --repository=[REPO]]\n' + f' slpkg [{self.yellow}OPTIONS{self.endc}] [-P, --parallel, -B, --binary, -O, --bin-repo=[REPO]]\n' f' slpkg [{self.yellow}OPTIONS{self.endc}] [-z, --directory=[PATH]]\n' " \nIf you need more information please try 'slpkg --help'.") @@ -83,7 +83,7 @@ class Usage(Configs): f' {self.yellow}-G, --generate-only{self.endc} Generates only the SLACKBUILDS.TXT file.\n' f' {self.yellow}-P, --parallel{self.endc} Download files in parallel.\n' f' {self.yellow}-B, --binary{self.endc} Switch with binaries repositories.\n' - f' {self.yellow}-O, --repository={self.endc}[REPO] Set the binary repository.\n' + f' {self.yellow}-O, --bin-repo={self.endc}[REPO] Set the binary repository.\n' f' {self.yellow}-z, --directory={self.endc}[PATH] Download files to a specific path.\n' '\n -h, --help Show this message and exit.\n' ' -v, --version Print version and exit.\n'