mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-25 14:19:07 +08:00
Extract functions for output formatting
This commit is contained in:
parent
1ed61c4de8
commit
60b49cf4f7
@ -14,6 +14,8 @@ namespace vcpkg::Dependencies
|
||||
AUTO_SELECTED
|
||||
};
|
||||
|
||||
std::string to_output_string(RequestType request_type, const CStringView s);
|
||||
|
||||
enum class InstallPlanType
|
||||
{
|
||||
UNKNOWN,
|
||||
|
@ -121,32 +121,18 @@ namespace vcpkg::Commands::Remove
|
||||
}
|
||||
}
|
||||
|
||||
auto print_lambda = [](const PackageSpecWithRemovePlan* p) { return to_output_string(p->plan.request_type, p->spec.to_string()); };
|
||||
|
||||
if (!not_installed.empty())
|
||||
{
|
||||
std::sort(not_installed.begin(), not_installed.end(), &PackageSpecWithRemovePlan::compare_by_name);
|
||||
System::println("The following packages are not installed, so not removed:\n%s",
|
||||
Strings::join("\n", not_installed, [](const PackageSpecWithRemovePlan* p)
|
||||
{
|
||||
return " " + p->spec.to_string();
|
||||
}));
|
||||
System::println("The following packages are not installed, so not removed:\n%s", Strings::join("\n", not_installed, print_lambda));
|
||||
}
|
||||
|
||||
if (!remove.empty())
|
||||
{
|
||||
std::sort(remove.begin(), remove.end(), &PackageSpecWithRemovePlan::compare_by_name);
|
||||
System::println("The following packages will be removed:\n%s",
|
||||
Strings::join("\n", remove, [](const PackageSpecWithRemovePlan* p)
|
||||
{
|
||||
switch (p->plan.request_type)
|
||||
{
|
||||
case RequestType::AUTO_SELECTED:
|
||||
return " * " + p->spec.to_string();
|
||||
case RequestType::USER_REQUESTED:
|
||||
return " " + p->spec.to_string();
|
||||
default:
|
||||
Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
}));
|
||||
System::println("The following packages will be removed:\n%s", Strings::join("\n", remove, print_lambda));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,19 @@
|
||||
|
||||
namespace vcpkg::Dependencies
|
||||
{
|
||||
std::string to_output_string(RequestType request_type, const CStringView s)
|
||||
{
|
||||
switch (request_type)
|
||||
{
|
||||
case RequestType::AUTO_SELECTED:
|
||||
return Strings::format(" * %s", s);
|
||||
case RequestType::USER_REQUESTED:
|
||||
return Strings::format(" %s", s);
|
||||
default:
|
||||
Checks::unreachable(VCPKG_LINE_INFO);
|
||||
}
|
||||
}
|
||||
|
||||
InstallPlanAction::InstallPlanAction() : plan_type(InstallPlanType::UNKNOWN), binary_pgh(nullopt), source_pgh(nullopt)
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user