Skip to content

Commit 1ba52d7

Browse files
committed
change options priority
1 parent fdf04b8 commit 1ba52d7

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

libmamba/src/api/list.cpp

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ namespace mamba
2222
{
2323
struct list_options
2424
{
25-
bool full_name;
26-
bool no_pip;
27-
bool reverse;
28-
bool explicit_;
29-
bool md5;
30-
bool canonical;
25+
bool full_name = false;
26+
bool no_pip = false;
27+
bool reverse = false;
28+
bool explicit_ = false;
29+
bool md5 = false;
30+
bool canonical = false;
3131
};
3232

3333
struct formatted_pkg
3434
{
35-
std::string name, version, build, channel, url, md5, build_string;
35+
std::string name, version, build, channel, url, md5, build_string, platform;
3636
};
3737

3838
bool compare_alphabetically(const formatted_pkg& a, const formatted_pkg& b)
@@ -169,6 +169,7 @@ namespace mamba
169169
obj["channel"] = get_formatted_channel(pkg_info, channels.front());
170170
obj["base_url"] = get_base_url(pkg_info, channels.front());
171171
obj["url"] = pkg_info.package_url;
172+
obj["md5"] = pkg_info.md5;
172173
obj["build_number"] = pkg_info.build_number;
173174
obj["build_string"] = pkg_info.build_string;
174175
obj["dist_name"] = pkg_info.str();
@@ -203,6 +204,7 @@ namespace mamba
203204
formatted_pkgs.url = package.second.package_url;
204205
formatted_pkgs.md5 = package.second.md5;
205206
formatted_pkgs.build_string = package.second.build_string;
207+
formatted_pkgs.platform = package.second.platform;
206208
packages.push_back(formatted_pkgs);
207209
}
208210
}
@@ -212,15 +214,13 @@ namespace mamba
212214
std::sort(packages.begin(), packages.end(), comparator);
213215

214216
// format and print output
215-
if (options.canonical)
217+
if (options.explicit_)
216218
{
217-
for (auto p : packages)
219+
if (options.canonical)
218220
{
219-
std::cout << p.name << "-" << p.version << "-" << p.build_string << std::endl;
221+
std::cout << "Warning: Option --canonical ignored because of --explicit \n"
222+
<< std::endl;
220223
}
221-
}
222-
else if (options.explicit_)
223-
{
224224
for (auto p : packages)
225225
{
226226
if (options.md5)
@@ -233,6 +233,14 @@ namespace mamba
233233
}
234234
}
235235
}
236+
else if (options.canonical)
237+
{
238+
for (auto p : packages)
239+
{
240+
std::cout << p.channel << "/" << p.platform << "::" << p.name << "-"
241+
<< p.version << "-" << p.build_string << std::endl;
242+
}
243+
}
236244
else
237245
{
238246
auto requested_specs = prefix_data.history().get_requested_specs_map();

micromamba/src/list.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ init_list_parser(CLI::App* subcom, Configuration& config)
5050
);
5151
subcom->add_flag("--md5", md5.get_cli_config<bool>(), md5.description());
5252

53-
auto& canonical = config.insert(Configurable("canonical", false)
54-
.group("cli")
55-
.description("Output canonical names of packages only."));
53+
auto& canonical = config.insert(
54+
Configurable("canonical", false)
55+
.group("cli")
56+
.description("Output canonical names of packages only. Ignored if --explicit.")
57+
);
5658
subcom->add_flag("-c,--canonical", canonical.get_cli_config<bool>(), canonical.description());
5759
}
5860

micromamba/tests/test_list.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,10 @@ def test_list_canonical(
118118

119119
outputs_list = res.strip().split("\n")[2:]
120120
if canonical_flag == "--canonical":
121-
items = ["conda-forge", "/", " "]
121+
items = ["conda-forge/", "::"]
122122
for output in outputs_list:
123-
assert all(i not in output for i in items)
123+
assert all(i in output for i in items)
124+
assert " " not in output
124125

125126

126127
@pytest.mark.parametrize("quiet_flag", ["", "-q", "--quiet"])

0 commit comments

Comments
 (0)