Skip to content

feat: add envs flag to info command #3837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Mar 5, 2025
Merged

Conversation

SandrineP
Copy link
Member

@SandrineP SandrineP commented Feb 24, 2025

Adds one of the missing sub-command #3535

Copy link
Member

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--base and --envs are incompatible, so we need to adapt test_subcommand accordingly.

if (options.base)
if (options.print_licenses)
{
const std::vector<std::pair<std::string, std::string>> licenses = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would go with static const (or static constexpr but that might work only in higher C++ versions)

if (options.print_licenses)
{
const std::vector<std::pair<std::string, std::string>> licenses = {
{ "micromamba",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this will easilly get out of sync (it probably already was in the original code). Do we have any other way to gather this information automatically?

Also after this change this data is embedded in the library, so these are the dependencies of the library only? What about the dependencies specific to mamba/micromamba?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's treat this in another PR?

{ "zstd",
"BSD license, Copyright (c) 2016-present, Facebook, Inc. All rights reserved." },
};
for (const auto& [dep, text] : licenses)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We create a vector of tuple, fill it with a predefined vector of pair (which are 2-ary tuples) then pass them to a function only taking a vector of tuples to transform it in an array to be processed as json. That looks like a lot of unnecessary work, but it's mostly because info_json_print only take a vector of print, when it's code really just need any sequence of 2-ary aggregations.

Suggestion: make info_json_print template, it should take any type that works as a sequence of elements that can be deconstruct to 2 values (as it is currently implemented). Then here call it directly with licences, no need to fill any container. (ping me if you need help with that)

InfoOptions options
)
void
print_info(Context& ctx, ChannelContext& channel_context, Configuration& config, InfoOptions options)
{
assert(&ctx == &config.context());

std::vector<std::tuple<std::string, nlohmann::json>> items;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like items should start it's life after all the if because every one of theme will return and creating that object here doesnt help with their code. The only situation where we actually need it is after all the if, line items.push_back({ "libmamba version", version() });.

@SandrineP SandrineP marked this pull request as ready for review March 4, 2025 09:18
Copy link
Member

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review hints a problem which is unrelated to the scope of this PR, which was existing before, but which I think which must be resolved nevertheless in another PR.

Copy link
Member

@jjerphan jjerphan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Thank you, @SandrineP.

if (options.print_licenses)
{
const std::vector<std::pair<std::string, std::string>> licenses = {
{ "micromamba",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's treat this in another PR?

@JohanMabille JohanMabille merged commit b6b1143 into mamba-org:main Mar 5, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release::bug_fixes For PRs fixing bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants