Skip to content

Commit b5d26d9

Browse files
committed
add explicit subcommand
1 parent 4a69e30 commit b5d26d9

File tree

2 files changed

+37
-16
lines changed

2 files changed

+37
-16
lines changed

libmamba/src/api/list.cpp

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ namespace mamba
2525
bool full_name;
2626
bool no_pip;
2727
bool reverse;
28+
bool explicit_;
2829
};
2930

3031
struct formatted_pkg
3132
{
32-
std::string name, version, build, channel;
33+
std::string name, version, build, channel, url;
3334
};
3435

3536
bool compare_alphabetically(const formatted_pkg& a, const formatted_pkg& b)
@@ -134,6 +135,7 @@ namespace mamba
134135
pkg_info.platform
135136
);
136137
}
138+
obj["url"] = pkg_info.package_url;
137139
obj["build_number"] = pkg_info.build_number;
138140
obj["build_string"] = pkg_info.build_string;
139141
obj["dist_name"] = pkg_info.str();
@@ -163,6 +165,7 @@ namespace mamba
163165
formatted_pkgs.name = package.second.name;
164166
formatted_pkgs.version = package.second.version;
165167
formatted_pkgs.build = package.second.build_string;
168+
formatted_pkgs.url = package.second.package_url;
166169
if (package.second.channel.find("https://repo.anaconda.com/pkgs/") == 0)
167170
{
168171
formatted_pkgs.channel = "";
@@ -190,25 +193,34 @@ namespace mamba
190193
std::sort(packages.begin(), packages.end(), comparator);
191194

192195
// format and print table
193-
printers::Table t({ "Name", "Version", "Build", "Channel" });
194-
t.set_alignment({ printers::alignment::left,
195-
printers::alignment::left,
196-
printers::alignment::left,
197-
printers::alignment::left });
198-
t.set_padding({ 2, 2, 2, 2 });
199-
200-
for (auto p : packages)
196+
if (options.explicit_)
201197
{
202-
printers::FormattedString formatted_name(p.name);
203-
if (requested_specs.find(p.name) != requested_specs.end())
198+
for (auto p : packages)
204199
{
205-
formatted_name = printers::FormattedString(p.name);
206-
formatted_name.style = ctx.graphics_params.palette.user;
200+
std::cout << p.url << std::endl;
207201
}
208-
t.add_row({ formatted_name, p.version, p.build, p.channel });
209202
}
210-
211-
t.print(std::cout);
203+
else
204+
{
205+
printers::Table t({ "Name", "Version", "Build", "Channel" });
206+
t.set_alignment({ printers::alignment::left,
207+
printers::alignment::left,
208+
printers::alignment::left,
209+
printers::alignment::left });
210+
t.set_padding({ 2, 2, 2, 2 });
211+
212+
for (auto p : packages)
213+
{
214+
printers::FormattedString formatted_name(p.name);
215+
if (requested_specs.find(p.name) != requested_specs.end())
216+
{
217+
formatted_name = printers::FormattedString(p.name);
218+
formatted_name.style = ctx.graphics_params.palette.user;
219+
}
220+
t.add_row({ formatted_name, p.version, p.build, p.channel });
221+
}
222+
t.print(std::cout);
223+
}
212224
}
213225
}
214226

@@ -228,6 +240,7 @@ namespace mamba
228240
options.full_name = config.at("full_name").value<bool>();
229241
options.no_pip = config.at("no_pip").value<bool>();
230242
options.reverse = config.at("reverse").value<bool>();
243+
options.explicit_ = config.at("explicit_").value<bool>();
231244

232245
auto channel_context = ChannelContext::make_conda_compatible(config.context());
233246
detail::list_packages(config.context(), regex, channel_context, std::move(options));

micromamba/src/list.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ init_list_parser(CLI::App* subcom, Configuration& config)
3838
Configurable("reverse", false).group("cli").description("List installed packages in reverse order.")
3939
);
4040
subcom->add_flag("--reverse", reverse.get_cli_config<bool>(), reverse.description());
41+
42+
auto& explicit_ = config.insert(Configurable("explicit_", false)
43+
.group("cli")
44+
.description("List explicitly all installed packages with URL."
45+
));
46+
subcom->add_flag("--explicit", explicit_.get_cli_config<bool>(), explicit_.description());
47+
48+
4149
// TODO: implement this in libmamba/list.cpp
4250
/*auto& canonical = config.insert(Configurable("canonical", false)
4351
.group("cli")

0 commit comments

Comments
 (0)