From 84ed16743988051b2e41cb5c66409370e6a6d5fe Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Wed, 5 Apr 2017 14:20:49 -0700 Subject: [PATCH] Introduce `vcpkg depend-info` command --- toolsrc/include/vcpkg_Commands.h | 5 +++++ toolsrc/src/commands_available_commands.cpp | 1 + toolsrc/src/commands_depends.cpp | 25 +++++++++++++++++++++ toolsrc/vcpkglib/vcpkglib.vcxproj | 1 + toolsrc/vcpkglib/vcpkglib.vcxproj.filters | 3 +++ 5 files changed, 35 insertions(+) create mode 100644 toolsrc/src/commands_depends.cpp diff --git a/toolsrc/include/vcpkg_Commands.h b/toolsrc/include/vcpkg_Commands.h index 227c44379d..db15a10fd2 100644 --- a/toolsrc/include/vcpkg_Commands.h +++ b/toolsrc/include/vcpkg_Commands.h @@ -86,6 +86,11 @@ namespace vcpkg::Commands void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); } + namespace DependInfo + { + void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); + } + namespace Search { void perform_and_exit(const VcpkgCmdArguments& args, const VcpkgPaths& paths); diff --git a/toolsrc/src/commands_available_commands.cpp b/toolsrc/src/commands_available_commands.cpp index 1af82eb8ab..37d3321f88 100644 --- a/toolsrc/src/commands_available_commands.cpp +++ b/toolsrc/src/commands_available_commands.cpp @@ -26,6 +26,7 @@ namespace vcpkg::Commands {"integrate", &Integrate::perform_and_exit}, {"owns", &Owns::perform_and_exit}, {"update", &Update::perform_and_exit}, + {"depend-info", &DependInfo::perform_and_exit}, {"edit", &Edit::perform_and_exit}, {"create", &Create::perform_and_exit}, {"import", &Import::perform_and_exit}, diff --git a/toolsrc/src/commands_depends.cpp b/toolsrc/src/commands_depends.cpp new file mode 100644 index 0000000000..a61ac534e9 --- /dev/null +++ b/toolsrc/src/commands_depends.cpp @@ -0,0 +1,25 @@ +#include "pch.h" +#include "vcpkg_Commands.h" +#include "vcpkg_System.h" +#include "Paragraphs.h" +#include "vcpkg_Strings.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); + args.check_and_get_optional_command_arguments({}); + + const std::vector source_paragraphs = Paragraphs::load_all_ports(paths.ports); + + for (const SourceParagraph& source_paragraph : source_paragraphs) + { + auto s = Strings::join(", ", source_paragraph.depends, [](const Dependency& d) { return d.name; }); + System::println("%s: %s", source_paragraph.name, s); + } + + Checks::exit_success(VCPKG_LINE_INFO); + } +} diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj b/toolsrc/vcpkglib/vcpkglib.vcxproj index de1f05ad96..1a8dd975bb 100644 --- a/toolsrc/vcpkglib/vcpkglib.vcxproj +++ b/toolsrc/vcpkglib/vcpkglib.vcxproj @@ -185,6 +185,7 @@ + diff --git a/toolsrc/vcpkglib/vcpkglib.vcxproj.filters b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters index 909681fd52..b51958c57c 100644 --- a/toolsrc/vcpkglib/vcpkglib.vcxproj.filters +++ b/toolsrc/vcpkglib/vcpkglib.vcxproj.filters @@ -180,6 +180,9 @@ Source Files + + Source Files +