[vcpkg] Refactor VcpkgCmdArguments to not utilize global state
MODIFY
include/vcpkg/vcpkgcmdarguments.h
include/vcpkg/vcpkgcmdarguments.h
@@ -79,6 +79,8 @@ namespace vcpkg
Optional<bool> sendmetrics = nullopt;
Optional<bool> printmetrics = nullopt;
+ // feature flags
+ Optional<bool> featurepackages = nullopt;
std::string command;
std::vector<std::string> command_arguments;

MODIFY
src/vcpkg.cpp
src/vcpkg.cpp
@@ -265,6 +265,7 @@ int main(const int argc, const char* const* const argv)
const VcpkgCmdArguments args = VcpkgCmdArguments::create_from_command_line(argc, argv);
+ if (const auto p = args.featurepackages.get()) GlobalState::feature_packages = *p;
if (const auto p = args.printmetrics.get()) Metrics::g_metrics.lock()->set_print_metrics(*p);
if (const auto p = args.sendmetrics.get()) Metrics::g_metrics.lock()->set_send_metrics(*p);
if (const auto p = args.debug.get()) GlobalState::debugging = *p;

MODIFY
src/vcpkg/vcpkgcmdarguments.cpp
src/vcpkg/vcpkgcmdarguments.cpp
@@ -126,12 +126,13 @@ namespace vcpkg
}
if (arg == "--featurepackages")
{
- GlobalState::feature_packages = true;
+ parse_switch(true, "featurepackages", args.featurepackages);
continue;
}
if (arg == "--no-featurepackages")
{
- GlobalState::feature_packages = false;
+ parse_switch(false, "featurepackages", args.featurepackages);
+ continue;
continue;
}

[vcpkg] Refactor VcpkgCmdArguments to not utilize global state