From 370f99f7ba1f3a139802aa691e2cfa1f798444c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= Date: Tue, 16 May 2023 12:19:21 +0200 Subject: [PATCH] group list/info: add `--contains-pkgs` option --- dnf5/commands/group/arguments.hpp | 12 ++++++++++++ dnf5/commands/group/group_info.cpp | 4 ++++ dnf5/commands/group/group_info.hpp | 1 + dnf5/commands/group/group_list.cpp | 4 ++++ dnf5/commands/group/group_list.hpp | 1 + doc/changes.rst | 1 + doc/commands/group.8.rst | 3 +++ 7 files changed, 26 insertions(+) diff --git a/dnf5/commands/group/arguments.hpp b/dnf5/commands/group/arguments.hpp index bf7b464f6..e0f04d1b2 100644 --- a/dnf5/commands/group/arguments.hpp +++ b/dnf5/commands/group/arguments.hpp @@ -50,6 +50,18 @@ class GroupInstalledOption : public libdnf::cli::session::BoolOption { }; +class GroupContainsPkgsOption : public libdnf::cli::session::StringListOption { +public: + explicit GroupContainsPkgsOption(libdnf::cli::session::Command & command) + : StringListOption( + command, + "contains-pkgs", + '\0', + _("Show only groups containing packages with specified names. List option, supports globs."), + "PACKAGE_NAME,...") {} +}; + + class GroupSpecArguments : public libdnf::cli::session::StringArgumentList { public: GroupSpecArguments(libdnf::cli::session::Command & command, int nargs) diff --git a/dnf5/commands/group/group_info.cpp b/dnf5/commands/group/group_info.cpp index f2abd3080..3fc84b9d0 100644 --- a/dnf5/commands/group/group_info.cpp +++ b/dnf5/commands/group/group_info.cpp @@ -38,6 +38,7 @@ void GroupInfoCommand::set_argument_parser() { // TODO(dmach): set_conflicting_args({available, installed}); hidden = std::make_unique(*this); group_specs = std::make_unique(*this); + group_pkg_contains = std::make_unique(*this); } void GroupInfoCommand::configure() { @@ -69,6 +70,9 @@ void GroupInfoCommand::run() { if (available->get_value()) { query.filter_installed(false); } + if (!group_pkg_contains->get_value().empty()) { + query.filter_package_name(group_pkg_contains->get_value(), libdnf::sack::QueryCmp::IGLOB); + } for (auto group : query.list()) { libdnf::cli::output::print_groupinfo_table(group); diff --git a/dnf5/commands/group/group_info.hpp b/dnf5/commands/group/group_info.hpp index 96a124e67..7efdafc47 100644 --- a/dnf5/commands/group/group_info.hpp +++ b/dnf5/commands/group/group_info.hpp @@ -42,6 +42,7 @@ class GroupInfoCommand : public Command { std::unique_ptr installed{nullptr}; std::unique_ptr hidden{nullptr}; std::unique_ptr group_specs{nullptr}; + std::unique_ptr group_pkg_contains{nullptr}; }; diff --git a/dnf5/commands/group/group_list.cpp b/dnf5/commands/group/group_list.cpp index 72e659b4b..4658d9e3e 100644 --- a/dnf5/commands/group/group_list.cpp +++ b/dnf5/commands/group/group_list.cpp @@ -38,6 +38,7 @@ void GroupListCommand::set_argument_parser() { // TODO(dmach): set_conflicting_args({available, installed}); hidden = std::make_unique(*this); group_specs = std::make_unique(*this); + group_pkg_contains = std::make_unique(*this); } void GroupListCommand::configure() { @@ -69,6 +70,9 @@ void GroupListCommand::run() { if (available->get_value()) { query.filter_installed(false); } + if (!group_pkg_contains->get_value().empty()) { + query.filter_package_name(group_pkg_contains->get_value(), libdnf::sack::QueryCmp::IGLOB); + } libdnf::cli::output::print_grouplist_table(query.list()); } diff --git a/dnf5/commands/group/group_list.hpp b/dnf5/commands/group/group_list.hpp index e5da39d6c..b6e055d24 100644 --- a/dnf5/commands/group/group_list.hpp +++ b/dnf5/commands/group/group_list.hpp @@ -44,6 +44,7 @@ class GroupListCommand : public Command { std::unique_ptr installed{nullptr}; std::unique_ptr hidden{nullptr}; std::unique_ptr group_specs{nullptr}; + std::unique_ptr group_pkg_contains{nullptr}; }; diff --git a/doc/changes.rst b/doc/changes.rst index 42531b75b..d5071f2a4 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -105,6 +105,7 @@ Repoquery command * Dropped: `-a/--all`, `--alldeps`, `--nevra` options, their behavior is and has been the default for both dnf4 and dnf5. The options are no longer needed. * Dopped: `--nvr`, `--envra` options. They are no longer supported. + * Moved `--groupmember` option to the Group info and list commands and renamed to `--contains-pkgs`. Upgrade command --------------- diff --git a/doc/commands/group.8.rst b/doc/commands/group.8.rst index 737c42020..081745ce9 100644 --- a/doc/commands/group.8.rst +++ b/doc/commands/group.8.rst @@ -88,6 +88,9 @@ Options ``--no-packages`` | Used with ``install`` and ``remove`` commands to operate exclusively on the groups without manipulating any packages. +``--contains-pkgs`` + | Show only groups containing packges with specified names. List option, supports globs. + Examples ========