2016-09-19 11:50:08 +08:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-29 08:27:07 +08:00
|
|
|
#include "vcpkg_optional.h"
|
2016-09-19 11:50:08 +08:00
|
|
|
#include <memory>
|
2017-07-27 04:54:28 +08:00
|
|
|
#include <unordered_map>
|
2016-09-19 11:50:08 +08:00
|
|
|
#include <unordered_set>
|
2017-04-28 08:56:06 +08:00
|
|
|
#include <vector>
|
2016-09-19 11:50:08 +08:00
|
|
|
|
|
|
|
namespace vcpkg
|
|
|
|
{
|
2017-07-27 04:54:28 +08:00
|
|
|
struct ParsedArguments
|
|
|
|
{
|
|
|
|
std::unordered_set<std::string> switches;
|
|
|
|
std::unordered_map<std::string, std::string> settings;
|
|
|
|
};
|
|
|
|
|
2017-04-04 07:00:17 +08:00
|
|
|
struct VcpkgCmdArguments
|
2016-09-19 11:50:08 +08:00
|
|
|
{
|
2017-04-04 07:00:17 +08:00
|
|
|
static VcpkgCmdArguments create_from_command_line(const int argc, const wchar_t* const* const argv);
|
|
|
|
static VcpkgCmdArguments create_from_arg_sequence(const std::string* arg_begin, const std::string* arg_end);
|
2016-09-19 11:50:08 +08:00
|
|
|
|
|
|
|
std::unique_ptr<std::string> vcpkg_root_dir;
|
2017-04-11 04:01:43 +08:00
|
|
|
std::unique_ptr<std::string> triplet;
|
2017-04-29 08:27:07 +08:00
|
|
|
Optional<bool> debug = nullopt;
|
|
|
|
Optional<bool> sendmetrics = nullopt;
|
|
|
|
Optional<bool> printmetrics = nullopt;
|
2016-09-19 11:50:08 +08:00
|
|
|
|
|
|
|
std::string command;
|
|
|
|
std::vector<std::string> command_arguments;
|
2017-04-29 03:38:13 +08:00
|
|
|
std::unordered_set<std::string> check_and_get_optional_command_arguments(
|
2017-07-27 04:54:28 +08:00
|
|
|
const std::vector<std::string>& valid_options) const
|
|
|
|
{
|
|
|
|
return std::move(check_and_get_optional_command_arguments(valid_options, {}).switches);
|
|
|
|
}
|
|
|
|
|
|
|
|
ParsedArguments check_and_get_optional_command_arguments(const std::vector<std::string>& valid_switches,
|
|
|
|
const std::vector<std::string>& valid_settings) const;
|
2016-09-19 11:50:08 +08:00
|
|
|
|
2016-10-01 02:24:04 +08:00
|
|
|
void check_max_arg_count(const size_t expected_arg_count) const;
|
2016-12-13 07:03:36 +08:00
|
|
|
void check_max_arg_count(const size_t expected_arg_count, const std::string& example_text) const;
|
2016-10-01 02:24:04 +08:00
|
|
|
void check_min_arg_count(const size_t expected_arg_count) const;
|
2016-12-13 07:03:36 +08:00
|
|
|
void check_min_arg_count(const size_t expected_arg_count, const std::string& example_text) const;
|
2016-10-01 02:24:04 +08:00
|
|
|
void check_exact_arg_count(const size_t expected_arg_count) const;
|
2016-12-13 07:03:36 +08:00
|
|
|
void check_exact_arg_count(const size_t expected_arg_count, const std::string& example_text) const;
|
2016-10-01 02:24:04 +08:00
|
|
|
|
2016-09-19 11:50:08 +08:00
|
|
|
private:
|
2017-07-27 04:54:28 +08:00
|
|
|
std::unordered_map<std::string, Optional<std::string>> optional_command_arguments;
|
2016-09-19 11:50:08 +08:00
|
|
|
};
|
|
|
|
}
|