From f0433837ef5b74d62a029c1907e1ead94baf38fa Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sun, 7 Apr 2024 21:51:21 +0300 Subject: [PATCH] Added --pkg-version option --- ChangeLog.txt | 1 + slpkg/main.py | 2 ++ slpkg/search.py | 11 +++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 91515615..0952436d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -3,6 +3,7 @@ ### 5.0.5 - 07/04/2024 - Added: * Added maximum parallel for downloading in the config file + * Added --pkg-version option in search command - Updated: * Updated to exclude packages from slack_extra repository (Thanks to Marav) diff --git a/slpkg/main.py b/slpkg/main.py index 942a99f8..422c6d4c 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -225,6 +225,8 @@ class Menu(Configs): self.flag_short_search, self.flag_repository, self.flag_short_repository, + self.flag_pkg_version, + self.flag_short_pkg_version, self.flag_no_case, self.flag_short_no_case ], diff --git a/slpkg/search.py b/slpkg/search.py index 21f7cf4d..104fbca4 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -25,6 +25,9 @@ class SearchPackage(Configs): self.option_for_no_case: bool = self.utils.is_option( ('-m', '--no-case'), flags) + self.option_for_pkg_version: bool = self.utils.is_option( + ('-p', '--pkg-version'), flags) + def search(self) -> None: if self.repository == '*': self.search_to_all_repositories() @@ -55,6 +58,7 @@ class SearchPackage(Configs): } def summary_of_searching(self) -> None: + version: str = '' try: repo_length: int = max(len(repo['repository']) for repo in self.data_dict.values()) except ValueError: @@ -67,8 +71,11 @@ class SearchPackage(Configs): if self.matching: for item in self.data_dict.values(): - print(f"{item['repository']:<{repo_length}}: {self.cyan}{item['name']:<{name_length}}{self.endc} " - f"{self.yellow}{item['version']}{self.endc}") + if self.option_for_pkg_version: + version: str = item['version'] + + print(f"{item['repository']:<{repo_length}} : {self.cyan}{item['name']:<{name_length}}{self.endc} " + f"{self.yellow}{version}{self.endc}") print(f'\n{self.grey}Total found {self.matching} packages.{self.endc}') else: