Skip to content

Commit

Permalink
modules: Sort the module info table
Browse files Browse the repository at this point in the history
Also removes the note to sort the module list table, because it's
already sorted.
  • Loading branch information
pkratoch authored and jan-kolarik committed Dec 19, 2023
1 parent 62f2883 commit 7fa85e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 7 additions & 3 deletions include/libdnf5-cli/output/moduleinfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ along with libdnf. If not, see <https://www.gnu.org/licenses/>.
#include <libdnf5/utils/bgettext/bgettext-lib.h>
#include <libsmartcols/libsmartcols.h>

#include <set>
#include <map>
#include <string>

namespace libdnf5::cli::output {
Expand Down Expand Up @@ -98,9 +98,13 @@ void ModuleInfo::add_module_item(ModuleItem & module_item) {

template <class Query>
void print_moduleinfo_table(Query & module_list) {
for (auto & module_item : module_list) {
std::map<std::string, libdnf5::module::ModuleItem> module_map;
for (const auto & module_item : module_list) {
module_map.emplace(module_item.get_full_identifier() + ":" + module_item.get_repo_id(), module_item);
}
for (auto & module_item : module_map) {
libdnf5::cli::output::ModuleInfo module_info;
module_info.add_module_item(module_item);
module_info.add_module_item(module_item.second);
module_info.print();
std::cout << std::endl;
}
Expand Down
1 change: 0 additions & 1 deletion include/libdnf5-cli/output/modulelist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ static void add_line_into_modulelist_table(

template <class Query>
void print_modulelist_table(Query & module_list) {
// TODO(pkratoch): Sort the table
struct libscols_table * table = create_modulelist_table();
std::set<std::pair<std::string, std::string>> name_stream_pairs;
for (auto & module_item : module_list) {
Expand Down

0 comments on commit 7fa85e1

Please sign in to comment.