-
Notifications
You must be signed in to change notification settings - Fork 387
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
Conversation
There was a problem hiding this 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.
libmamba/src/api/info.cpp
Outdated
if (options.base) | ||
if (options.print_licenses) | ||
{ | ||
const std::vector<std::pair<std::string, std::string>> licenses = { |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
libmamba/src/api/info.cpp
Outdated
{ "zstd", | ||
"BSD license, Copyright (c) 2016-present, Facebook, Inc. All rights reserved." }, | ||
}; | ||
for (const auto& [dep, text] : licenses) |
There was a problem hiding this comment.
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)
libmamba/src/api/info.cpp
Outdated
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; |
There was a problem hiding this comment.
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() });
.
There was a problem hiding this 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.
There was a problem hiding this 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", |
There was a problem hiding this comment.
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?
Adds one of the missing sub-command #3535