2016-09-18 20:50:08 -07:00
|
|
|
#pragma once
|
|
|
|
|
2017-10-13 20:58:00 -07:00
|
|
|
#include <vcpkg/base/cstringview.h>
|
2017-10-13 18:37:41 -07:00
|
|
|
#include <vcpkg/base/optional.h>
|
2017-10-13 20:58:00 -07:00
|
|
|
#include <vcpkg/base/span.h>
|
2017-10-13 18:37:41 -07:00
|
|
|
|
2016-09-18 20:50:08 -07:00
|
|
|
#include <memory>
|
2017-07-26 13:54:28 -07:00
|
|
|
#include <unordered_map>
|
2016-09-18 20:50:08 -07:00
|
|
|
#include <unordered_set>
|
2017-04-27 17:56:06 -07:00
|
|
|
#include <vector>
|
2016-09-18 20:50:08 -07:00
|
|
|
|
|
|
|
namespace vcpkg
|
|
|
|
{
|
2017-07-26 13:54:28 -07:00
|
|
|
struct ParsedArguments
|
|
|
|
{
|
|
|
|
std::unordered_set<std::string> switches;
|
|
|
|
std::unordered_map<std::string, std::string> settings;
|
|
|
|
};
|
|
|
|
|
2017-11-02 15:20:42 -07:00
|
|
|
struct VcpkgPaths;
|
|
|
|
|
|
|
|
struct CommandSwitch
|
|
|
|
{
|
|
|
|
std::string name;
|
|
|
|
CStringView short_help_text;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CommandSetting
|
2016-09-18 20:50:08 -07:00
|
|
|
{
|
2017-11-02 15:20:42 -07:00
|
|
|
std::string name;
|
|
|
|
CStringView short_help_text;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CommandOptionsStructure
|
|
|
|
{
|
|
|
|
Span<const CommandSwitch> switches;
|
|
|
|
Span<const CommandSetting> settings;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CommandStructure
|
|
|
|
{
|
|
|
|
std::string example_text;
|
|
|
|
|
|
|
|
size_t minimum_arity;
|
|
|
|
size_t maximum_arity;
|
|
|
|
|
|
|
|
CommandOptionsStructure options;
|
|
|
|
|
|
|
|
std::vector<std::string> (*valid_arguments)(const VcpkgPaths& paths);
|
|
|
|
};
|
|
|
|
|
2017-11-02 18:17:21 -07:00
|
|
|
void display_usage(const CommandStructure& command_structure);
|
|
|
|
|
2017-10-16 11:44:04 -07:00
|
|
|
#if defined(_WIN32)
|
2017-11-02 15:20:42 -07:00
|
|
|
using CommandLineCharType = wchar_t;
|
2017-10-16 11:44:04 -07:00
|
|
|
#else
|
2017-11-02 15:20:42 -07:00
|
|
|
using CommandLineCharType = char;
|
2017-10-16 11:44:04 -07:00
|
|
|
#endif
|
2017-11-02 15:20:42 -07:00
|
|
|
|
|
|
|
struct VcpkgCmdArguments
|
|
|
|
{
|
|
|
|
static VcpkgCmdArguments create_from_command_line(const int argc, const CommandLineCharType* const* const argv);
|
2017-04-03 16:00:17 -07:00
|
|
|
static VcpkgCmdArguments create_from_arg_sequence(const std::string* arg_begin, const std::string* arg_end);
|
2016-09-18 20:50:08 -07:00
|
|
|
|
|
|
|
std::unique_ptr<std::string> vcpkg_root_dir;
|
2017-04-10 13:01:43 -07:00
|
|
|
std::unique_ptr<std::string> triplet;
|
2017-04-28 17:27:07 -07:00
|
|
|
Optional<bool> debug = nullopt;
|
|
|
|
Optional<bool> sendmetrics = nullopt;
|
|
|
|
Optional<bool> printmetrics = nullopt;
|
2016-09-18 20:50:08 -07:00
|
|
|
|
|
|
|
std::string command;
|
|
|
|
std::vector<std::string> command_arguments;
|
2017-07-26 13:54:28 -07:00
|
|
|
|
2017-11-02 15:20:42 -07:00
|
|
|
ParsedArguments parse_arguments(const CommandStructure& command_structure) const;
|
2016-09-30 11:24:04 -07:00
|
|
|
|
2016-09-18 20:50:08 -07:00
|
|
|
private:
|
2017-07-26 13:54:28 -07:00
|
|
|
std::unordered_map<std::string, Optional<std::string>> optional_command_arguments;
|
2016-09-18 20:50:08 -07:00
|
|
|
};
|
|
|
|
}
|