aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2016-09-21 22:47:36 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2016-09-21 22:47:36 -0700
commit869a3b22ad9d13fa29b40751998127270365880b (patch)
tree139073d2c8bbfa11b86710bf2cda25d0941ce753 /toolsrc/src
parent63052551eff40b05b58a69b0af43a353500a5d72 (diff)
downloadvcpkg-869a3b22ad9d13fa29b40751998127270365880b.tar.gz
vcpkg-869a3b22ad9d13fa29b40751998127270365880b.zip
vcpkg search now does substring search
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/commands_search.cpp41
1 files changed, 29 insertions, 12 deletions
diff --git a/toolsrc/src/commands_search.cpp b/toolsrc/src/commands_search.cpp
index e3c51faaf..ce02e9c3b 100644
--- a/toolsrc/src/commands_search.cpp
+++ b/toolsrc/src/commands_search.cpp
@@ -8,15 +8,9 @@ namespace fs = std::tr2::sys;
namespace vcpkg
{
- void search_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
+ template <class Pred>
+ static void do_print(const vcpkg_paths& paths, Pred predicate)
{
- args.check_max_args(1);
-
- if (args.command_arguments.size() == 1)
- {
- System::println(System::color::warning, "Search strings are not yet implemented; showing full list of packages.");
- }
-
for (auto it = fs::directory_iterator(paths.ports); it != fs::directory_iterator(); ++it)
{
const fs::path& path = it->path();
@@ -27,15 +21,38 @@ namespace vcpkg
if (pghs.empty())
continue;
auto srcpgh = SourceParagraph(pghs[0]);
- std::cout << std::left
- << std::setw(20) << srcpgh.name << ' '
- << std::setw(16) << srcpgh.version << ' '
- << shorten_description(srcpgh.description) << '\n';
+
+ if (predicate(srcpgh.name))
+ {
+ std::cout << std::left
+ << std::setw(20) << srcpgh.name << ' '
+ << std::setw(16) << srcpgh.version << ' '
+ << shorten_description(srcpgh.description) << '\n';
+ }
}
catch (std::runtime_error const&)
{
}
}
+ }
+
+ void search_command(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths)
+ {
+ args.check_max_args(1);
+ if (args.command_arguments.size() == 0)
+ {
+ do_print(paths, [](std::string&) -> bool
+ {
+ return true;
+ });
+ exit(EXIT_SUCCESS);
+ }
+
+ // At this point there is 1 argument
+ do_print(paths, [&](std::string& port_name) -> bool
+ {
+ return Strings::case_insensitive_find(port_name, args.command_arguments[0]) != port_name.end();
+ });
System::println("\nIf your library is not listed, please open an issue at:\n"
" https://github.com/Microsoft/vcpkg/issues");