[vcpkg] Improve formatting of search and list. Fix gl2ps version.
MODIFY
include/vcpkglib.h
include/vcpkglib.h
@@ -36,5 +36,5 @@ namespace vcpkg
const fs::path& cmake_script,
const std::vector<CMakeVariable>& pass_variables);
- std::string shorten_description(const std::string& desc);
+ std::string shorten_text(const std::string& desc, size_t length);
} // namespace vcpkg

MODIFY
src/commands_list.cpp
src/commands_list.cpp
@@ -12,14 +12,14 @@ namespace vcpkg::Commands::List
{
if (FullDesc)
{
- System::println("%-27s %-16s %s", pgh.package.displayname(), pgh.package.version, pgh.package.description);
+ System::println("%-30s %-16s %s", pgh.package.displayname(), pgh.package.version, pgh.package.description);
}
else
{
- System::println("%-27s %-16s %s",
- pgh.package.displayname(),
- pgh.package.version,
- vcpkg::shorten_description(pgh.package.description));
+ System::println("%-30s %-16s %s",
+ vcpkg::shorten_text(pgh.package.displayname(), 30),
+ vcpkg::shorten_text(pgh.package.version, 16),
+ vcpkg::shorten_text(pgh.package.description, 71));
}
}

MODIFY
src/commands_search.cpp
src/commands_search.cpp
@@ -57,9 +57,9 @@ namespace vcpkg::Commands::Search
else
{
System::println("%-20s %-16s %s",
- source_paragraph.name,
- source_paragraph.version,
- vcpkg::shorten_description(source_paragraph.description));
+ vcpkg::shorten_text(source_paragraph.name, 20),
+ vcpkg::shorten_text(source_paragraph.version, 16),
+ vcpkg::shorten_text(source_paragraph.description, 81));
}
}
@@ -72,8 +72,8 @@ namespace vcpkg::Commands::Search
else
{
System::println("%-37s %s",
- name + "[" + feature_paragraph.name + "]",
- vcpkg::shorten_description(feature_paragraph.description));
+ vcpkg::shorten_text(name + "[" + feature_paragraph.name + "]", 37),
+ vcpkg::shorten_text(feature_paragraph.description, 81));
}
}

MODIFY
src/vcpkglib.cpp
src/vcpkglib.cpp
@@ -240,9 +240,10 @@ namespace vcpkg
LR"("%s" %s -P "%s")", cmake_exe.native(), cmd_cmake_pass_variables, cmake_script.generic_wstring());
}
- std::string shorten_description(const std::string& desc)
+ std::string shorten_text(const std::string& desc, size_t length)
{
+ Checks::check_exit(VCPKG_LINE_INFO, length >= 3);
auto simple_desc = std::regex_replace(desc, std::regex("\\s+"), " ");
- return simple_desc.size() <= 52 ? simple_desc : simple_desc.substr(0, 49) + "...";
+ return simple_desc.size() <= length ? simple_desc : simple_desc.substr(0, length - 3) + "...";
}
}

[vcpkg] Improve formatting of search and list. Fix gl2ps version.