[vcpkg] Refactor VcpkgCmdArguments to not utilize global state

This commit is contained in:
Robert Schumacher 2018-02-26 18:22:17 -08:00
parent e2980c8f91
commit a2e6ffd86d
3 changed files with 6 additions and 2 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;
}