-
Notifications
You must be signed in to change notification settings - Fork 379
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
feat: add export flag to list command #3780
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.
A few comments.
You might want to merge / rebase main
because #3793 has been merged in the meantime to fix the failing CI checks on Windows.
libmamba/src/api/list.cpp
Outdated
@@ -218,7 +219,11 @@ namespace mamba | |||
{ | |||
if (options.canonical) | |||
{ | |||
LOG_WARNING << "Option --canonical ignored because of --explicit"; | |||
LOG_WARNING << "Option --canonical ignored because of --explicit \n"; |
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.
LOG_*
add new lines implicitly.
LOG_WARNING << "Option --canonical ignored because of --explicit \n"; | |
LOG_WARNING << "Option --canonical ignored because of --explicit"; |
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.
Nitpick: this message might be slightly more explicit.
LOG_WARNING << "Option --canonical ignored because of --explicit \n"; | |
LOG_WARNING << "Option --canonical ignored because --explicit was provided"; |
libmamba/src/api/list.cpp
Outdated
} | ||
if (options.export_) | ||
{ | ||
LOG_WARNING << "Option --export ignored because of --explicit \n"; |
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.
LOG_WARNING << "Option --export ignored because of --explicit \n"; | |
LOG_WARNING << "Option --export ignored because of --explicit"; |
libmamba/src/api/list.cpp
Outdated
@@ -234,12 +239,23 @@ namespace mamba | |||
} | |||
else if (options.canonical) | |||
{ | |||
if (options.export_) | |||
{ | |||
LOG_WARNING << "Option --export ignored because of --explicit \n"; |
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.
Copy-paste mistake?
LOG_WARNING << "Option --export ignored because of --explicit \n"; | |
LOG_WARNING << "Option --export ignored because of --canonical"; |
micromamba/tests/test_list.py
Outdated
else: | ||
if canonical_flag == "--canonical": | ||
if canonical_flag in ["-c", "--canonical"]: | ||
items = ["conda-forge/", "::"] | ||
for output in outputs_list: | ||
assert all(i in output for i in items) | ||
assert " " not in output | ||
else: | ||
if export_flag in ["-e", "--export"]: |
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 can use elif
twice instead here.
micromamba/tests/test_list.py
Outdated
outputs_list = [i for i in outputs_list if not i.startswith("Warning")] | ||
outputs_list = [i for i in outputs_list if i != ""] |
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.
outputs_list = [i for i in outputs_list if not i.startswith("Warning")] | |
outputs_list = [i for i in outputs_list if i != ""] | |
outputs_list = [i for i in outputs_list if i != "" and not i.startswith("Warning")] |
micromamba/tests/test_list.py
Outdated
items = ["conda-forge/", "::", " "] | ||
for output in outputs_list: | ||
# assert all(i not in output for i in 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.
items = ["conda-forge/", "::", " "] | |
for output in outputs_list: | |
# assert all(i not in output for i in items) | |
items = ["conda-forge/", "::", " "] | |
for output in outputs_list: | |
assert all(i not in output for i in items) |
Also you might want to define items
only once before the first if
.
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.
Or alternatively:
items = ["conda-forge/", "::", " "] | |
for output in outputs_list: | |
# assert all(i not in output for i in items) | |
for output in outputs_list: |
micromamba/src/list.cpp
Outdated
Configurable("export", false) | ||
.group("cli") | ||
.description( | ||
"Output explicit, machine-readable requirement strings instead of human-readable lists of packages. Ignored if --explicit or --canonical." |
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.
"Output explicit, machine-readable requirement strings instead of human-readable lists of packages. Ignored if --explicit or --canonical." | |
"Output explicit, machine-readable requirement strings instead of human-readable lists of packages. Ignored if --explicit or --canonical is also provided." |
micromamba/tests/test_list.py
Outdated
items = ["conda-forge/", "::", " "] | ||
for output in outputs_list: | ||
# assert all(i not in output for i in items) | ||
assert output.count("=") == 2 |
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 is slightly more stricter.
assert output.count("=") == 2 | |
assert len(output.split("=")) == 3 |
Adds one of the missing sub-command #3535