diff options
| author | Robert Schumacher <roschuma@microsoft.com> | 2017-10-13 18:37:41 -0700 |
|---|---|---|
| committer | Robert Schumacher <roschuma@microsoft.com> | 2017-10-13 18:37:41 -0700 |
| commit | e17de99599a2f114faab1bb4821fbaad4d266c95 (patch) | |
| tree | 397fec8a85af3ef002c125ce013eceb60d27116d /toolsrc/src/vcpkg.cpp | |
| parent | 1fb5313a881fe0fcfd90dff5255045c8367ee00b (diff) | |
| download | vcpkg-e17de99599a2f114faab1bb4821fbaad4d266c95.tar.gz vcpkg-e17de99599a2f114faab1bb4821fbaad4d266c95.zip | |
[vcpkg] Re-layout all files using new organization scheme.
All filenames and directories are lowercase. Use dots for namespace separation.
Diffstat (limited to 'toolsrc/src/vcpkg.cpp')
| -rw-r--r-- | toolsrc/src/vcpkg.cpp | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/toolsrc/src/vcpkg.cpp b/toolsrc/src/vcpkg.cpp index 706c641fb..748b4f0ee 100644 --- a/toolsrc/src/vcpkg.cpp +++ b/toolsrc/src/vcpkg.cpp @@ -1,16 +1,18 @@ #define WIN32_LEAN_AND_MEAN #include <Windows.h> -#include "Paragraphs.h" -#include "metrics.h" -#include "vcpkg_Chrono.h" -#include "vcpkg_Commands.h" -#include "vcpkg_Files.h" -#include "vcpkg_GlobalState.h" -#include "vcpkg_Input.h" -#include "vcpkg_Strings.h" -#include "vcpkg_System.h" -#include "vcpkglib.h" +#include <vcpkg/base/chrono.h> +#include <vcpkg/base/files.h> +#include <vcpkg/base/strings.h> +#include <vcpkg/base/system.h> +#include <vcpkg/commands.h> +#include <vcpkg/globalstate.h> +#include <vcpkg/help.h> +#include <vcpkg/input.h> +#include <vcpkg/metrics.h> +#include <vcpkg/paragraphs.h> +#include <vcpkg/vcpkglib.h> + #pragma warning(push) #pragma warning(disable : 4768) #include <Shlobj.h> @@ -19,12 +21,15 @@ #include <fstream> #include <memory> +#pragma comment(lib, "ole32") +#pragma comment(lib, "shell32") + using namespace vcpkg; void invalid_command(const std::string& cmd) { System::println(System::Color::error, "invalid command: %s", cmd); - Commands::Help::print_usage(); + Help::print_usage(); Checks::exit_fail(VCPKG_LINE_INFO); } @@ -33,13 +38,26 @@ static void inner(const VcpkgCmdArguments& args) Metrics::g_metrics.lock()->track_property("command", args.command); if (args.command.empty()) { - Commands::Help::print_usage(); + Help::print_usage(); Checks::exit_fail(VCPKG_LINE_INFO); } - if (const auto command_function = Commands::find(args.command, Commands::get_available_commands_type_c())) + static const auto find_command = [&](auto&& commands) { + auto it = Util::find_if(commands, [&](auto&& commandc) { + return Strings::case_insensitive_ascii_compare(commandc.name, args.command); + }); + using std::end; + if (it != end(commands)) + { + return &*it; + } + else + return static_cast<decltype(&*it)>(nullptr); + }; + + if (const auto command_function = find_command(Commands::get_available_commands_type_c())) { - return command_function(args); + return command_function->function(args); } fs::path vcpkg_root_dir; @@ -74,9 +92,9 @@ static void inner(const VcpkgCmdArguments& args) Checks::check_exit(VCPKG_LINE_INFO, exit_code == 0, "Changing the working dir failed"); Commands::Version::warn_if_vcpkg_version_mismatch(paths); - if (const auto command_function = Commands::find(args.command, Commands::get_available_commands_type_b())) + if (const auto command_function = find_command(Commands::get_available_commands_type_b())) { - return command_function(args, paths); + return command_function->function(args, paths); } Triplet default_triplet; @@ -100,9 +118,9 @@ static void inner(const VcpkgCmdArguments& args) Input::check_triplet(default_triplet, paths); - if (const auto command_function = Commands::find(args.command, Commands::get_available_commands_type_a())) + if (const auto command_function = find_command(Commands::get_available_commands_type_a())) { - return command_function(args, paths, default_triplet); + return command_function->function(args, paths, default_triplet); } return invalid_command(args.command); @@ -202,7 +220,7 @@ int wmain(const int argc, const wchar_t* const* const argv) SetConsoleCP(65001); SetConsoleOutputCP(65001); - *GlobalState::timer.lock() = ElapsedTime::create_started(); + *GlobalState::timer.lock() = Chrono::ElapsedTime::create_started(); const std::string trimmed_command_line = trim_path_from_command_line(Strings::to_utf8(GetCommandLineW())); |
