aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src/commands_depends.cpp
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-08-09 13:16:09 -0700
committerAlexander Karatarakis <alkarata@microsoft.com>2017-08-09 13:16:09 -0700
commit052b34d4c5df0ade113514552621798ad0e32173 (patch)
tree1c7d4e35b9accc2d672397bf60492819f4767b57 /toolsrc/src/commands_depends.cpp
parentf57394c8944320748906b754c40950c3c9539089 (diff)
downloadvcpkg-052b34d4c5df0ade113514552621798ad0e32173.tar.gz
vcpkg-052b34d4c5df0ade113514552621798ad0e32173.zip
Add text filtering in `vcpkg depend-info`
Diffstat (limited to 'toolsrc/src/commands_depends.cpp')
-rw-r--r--toolsrc/src/commands_depends.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/toolsrc/src/commands_depends.cpp b/toolsrc/src/commands_depends.cpp
index ccfe58e4e..2d1fb658b 100644
--- a/toolsrc/src/commands_depends.cpp
+++ b/toolsrc/src/commands_depends.cpp
@@ -4,16 +4,44 @@
#include "vcpkg_Commands.h"
#include "vcpkg_Strings.h"
#include "vcpkg_System.h"
+#include "vcpkg_Util.h"
namespace vcpkg::Commands::DependInfo
{
void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths)
{
- static const std::string example = Commands::Help::create_example_string(R"###(depend-info)###");
- args.check_exact_arg_count(0, example);
+ static const std::string example = Commands::Help::create_example_string(R"###(depend-info [pat])###");
+ args.check_max_arg_count(1, example);
args.check_and_get_optional_command_arguments({});
- const auto source_control_files = Paragraphs::load_all_ports(paths.get_filesystem(), paths.ports);
+ std::vector<std::unique_ptr<SourceControlFile>> source_control_files =
+ Paragraphs::load_all_ports(paths.get_filesystem(), paths.ports);
+
+ if (args.command_arguments.size() == 1)
+ {
+ const std::string filter = args.command_arguments.at(0);
+
+ Util::erase_remove_if(source_control_files,
+ [&](const std::unique_ptr<SourceControlFile>& source_control_file) {
+
+ const SourceParagraph& source_paragraph = *source_control_file->core_paragraph;
+
+ if (Strings::case_insensitive_ascii_contains(source_paragraph.name, filter))
+ {
+ return false;
+ }
+
+ for (const Dependency& dependency : source_paragraph.depends)
+ {
+ if (Strings::case_insensitive_ascii_contains(dependency.name, filter))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ });
+ }
for (auto&& source_control_file : source_control_files)
{