Skip to content

Commit

Permalink
group list/info: add --contains-pkgs option
Browse files Browse the repository at this point in the history
  • Loading branch information
kontura committed May 17, 2023
1 parent 25033cd commit 7d3dfeb
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions dnf5/commands/group/arguments.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions dnf5/commands/group/group_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void GroupInfoCommand::set_argument_parser() {
// TODO(dmach): set_conflicting_args({available, installed});
hidden = std::make_unique<GroupHiddenOption>(*this);
group_specs = std::make_unique<GroupSpecArguments>(*this);
group_pkg_contains = std::make_unique<GroupContainsPkgsOption>(*this);
}

void GroupInfoCommand::configure() {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions dnf5/commands/group/group_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class GroupInfoCommand : public Command {
std::unique_ptr<GroupInstalledOption> installed{nullptr};
std::unique_ptr<GroupHiddenOption> hidden{nullptr};
std::unique_ptr<GroupSpecArguments> group_specs{nullptr};
std::unique_ptr<GroupContainsPkgsOption> group_pkg_contains{nullptr};
};


Expand Down
4 changes: 4 additions & 0 deletions dnf5/commands/group/group_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void GroupListCommand::set_argument_parser() {
// TODO(dmach): set_conflicting_args({available, installed});
hidden = std::make_unique<GroupHiddenOption>(*this);
group_specs = std::make_unique<GroupSpecArguments>(*this);
group_pkg_contains = std::make_unique<GroupContainsPkgsOption>(*this);
}

void GroupListCommand::configure() {
Expand Down Expand Up @@ -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());
}
Expand Down
1 change: 1 addition & 0 deletions dnf5/commands/group/group_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class GroupListCommand : public Command {
std::unique_ptr<GroupInstalledOption> installed{nullptr};
std::unique_ptr<GroupHiddenOption> hidden{nullptr};
std::unique_ptr<GroupSpecArguments> group_specs{nullptr};
std::unique_ptr<GroupContainsPkgsOption> group_pkg_contains{nullptr};
};


Expand Down
1 change: 1 addition & 0 deletions doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------------
Expand Down
3 changes: 3 additions & 0 deletions doc/commands/group.8.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
========

Expand Down

0 comments on commit 7d3dfeb

Please sign in to comment.