Skip to content

Commit

Permalink
nicely format explictly requested specs in micromamba list
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Feb 3, 2022
1 parent a5ba853 commit 228349f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion libmamba/include/mamba/core/output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ namespace mamba
none = 0,
red = 1 << 1,
green = 1 << 2,
yellow = 1 << 3
yellow = 1 << 3,
bold_blue = 1 << 4
};

struct FormattedString
Expand Down
11 changes: 9 additions & 2 deletions libmamba/src/api/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,12 @@ namespace mamba
return;
}

std::cout << "List of packages in environment: " << ctx.target_prefix << std::endl;
std::cout << "List of packages in environment: " << ctx.target_prefix << "\n\n";

formatted_pkg formatted_pkgs;

std::vector<formatted_pkg> packages;
auto requested_specs = prefix_data.history().get_requested_specs_map();

// order list of packages from prefix_data by alphabetical order
for (const auto& package : prefix_data.m_package_records)
Expand Down Expand Up @@ -124,7 +125,13 @@ namespace mamba

for (auto p : packages)
{
t.add_row({ p.name, p.version, p.build, p.channel });
printers::FormattedString formatted_name(p.name);
if (requested_specs.find(p.name) != requested_specs.end())
{
formatted_name = printers::FormattedString(p.name);
formatted_name.flag = printers::format::bold_blue;
}
t.add_row({ formatted_name, p.version, p.build, p.channel });
}

t.print(std::cout);
Expand Down
3 changes: 3 additions & 0 deletions libmamba/src/core/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ namespace mamba
if (static_cast<std::size_t>(row[j].flag)
& static_cast<std::size_t>(format::yellow))
out << termcolor::yellow;
if (static_cast<std::size_t>(row[j].flag)
& static_cast<std::size_t>(format::bold_blue))
out << termcolor::blue << termcolor::bold;
}
if (this->m_align[j] == alignment::left)
{
Expand Down

0 comments on commit 228349f

Please sign in to comment.