Updated cxxopts to 2.0.0.
Starting from version 2.0.0, cxxopts returns a ParseResult object instead of storing the results directly within the Options structure. Additionally, Booleans are handled slightly differently. These two changes required some minor adjustment of the command-line argument parsing code.
This commit is contained in:
parent
c283adc42a
commit
9fde2b8e1b
@ -48,12 +48,12 @@ class Command
|
|||||||
|
|
||||||
void parseOptions(int argc, char **argv)
|
void parseOptions(int argc, char **argv)
|
||||||
{
|
{
|
||||||
m_options.parse(argc, argv);
|
const auto parseResult = m_options.parse(argc, argv);
|
||||||
|
|
||||||
forEach(m_optionGroups,
|
forEach(m_optionGroups,
|
||||||
[&](auto &optionGroup)
|
[&](auto &optionGroup)
|
||||||
{
|
{
|
||||||
optionGroup.parse(m_options);
|
optionGroup.read(parseResult);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ struct OptionGroupBasic
|
|||||||
static constexpr const auto Name = "basic";
|
static constexpr const auto Name = "basic";
|
||||||
|
|
||||||
void addTo(cxxopts::Options &options);
|
void addTo(cxxopts::Options &options);
|
||||||
void parse(cxxopts::Options &options);
|
void read(const cxxopts::ParseResult &parseResult);
|
||||||
|
|
||||||
bool help = false;
|
bool help = false;
|
||||||
bool version = false;
|
bool version = false;
|
||||||
@ -44,7 +44,7 @@ struct OptionGroupOutput
|
|||||||
static constexpr const auto Name = "output";
|
static constexpr const auto Name = "output";
|
||||||
|
|
||||||
void addTo(cxxopts::Options &options);
|
void addTo(cxxopts::Options &options);
|
||||||
void parse(cxxopts::Options &options);
|
void read(const cxxopts::ParseResult &parseResult);
|
||||||
|
|
||||||
colorlog::ColorStream::ColorPolicy colorPolicy = colorlog::ColorStream::ColorPolicy::Auto;
|
colorlog::ColorStream::ColorPolicy colorPolicy = colorlog::ColorStream::ColorPolicy::Auto;
|
||||||
colorlog::Priority logPriority = colorlog::Priority::Info;
|
colorlog::Priority logPriority = colorlog::Priority::Info;
|
||||||
@ -57,7 +57,7 @@ struct OptionGroupParser
|
|||||||
static constexpr const auto Name = "parser";
|
static constexpr const auto Name = "parser";
|
||||||
|
|
||||||
void addTo(cxxopts::Options &options);
|
void addTo(cxxopts::Options &options);
|
||||||
void parse(cxxopts::Options &options);
|
void read(const cxxopts::ParseResult &parseResult);
|
||||||
|
|
||||||
std::vector<std::string> inputFiles;
|
std::vector<std::string> inputFiles;
|
||||||
pddl::Mode parsingMode = pddl::Mode::Strict;
|
pddl::Mode parsingMode = pddl::Mode::Strict;
|
||||||
|
@ -21,11 +21,11 @@ void OptionGroupBasic::addTo(cxxopts::Options &options)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void OptionGroupBasic::parse(cxxopts::Options &options)
|
void OptionGroupBasic::read(const cxxopts::ParseResult &parseResult)
|
||||||
{
|
{
|
||||||
help = options["help"].as<bool>();
|
help = (parseResult.count("help") > 0);
|
||||||
version = options["version"].as<bool>();
|
version = (parseResult.count("version") > 0);
|
||||||
warningsAsErrors = options["warnings-as-errors"].as<bool>();
|
warningsAsErrors = (parseResult.count("warnings-as-errors") > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -44,9 +44,9 @@ void OptionGroupOutput::addTo(cxxopts::Options &options)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void OptionGroupOutput::parse(cxxopts::Options &options)
|
void OptionGroupOutput::read(const cxxopts::ParseResult &parseResult)
|
||||||
{
|
{
|
||||||
const auto colorPolicyString = options["color"].as<std::string>();
|
const auto colorPolicyString = parseResult["color"].as<std::string>();
|
||||||
|
|
||||||
if (colorPolicyString == "auto")
|
if (colorPolicyString == "auto")
|
||||||
colorPolicy = colorlog::ColorStream::ColorPolicy::Auto;
|
colorPolicy = colorlog::ColorStream::ColorPolicy::Auto;
|
||||||
@ -57,7 +57,7 @@ void OptionGroupOutput::parse(cxxopts::Options &options)
|
|||||||
else
|
else
|
||||||
throw OptionException("unknown color policy “" + colorPolicyString + "”");
|
throw OptionException("unknown color policy “" + colorPolicyString + "”");
|
||||||
|
|
||||||
const auto logPriorityString = options["log-priority"].as<std::string>();
|
const auto logPriorityString = parseResult["log-priority"].as<std::string>();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -88,19 +88,19 @@ void OptionGroupParser::addTo(cxxopts::Options &options)
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void OptionGroupParser::parse(cxxopts::Options &options)
|
void OptionGroupParser::read(const cxxopts::ParseResult &parseResult)
|
||||||
{
|
{
|
||||||
const auto parsingModeString = options["parsing-mode"].as<std::string>();
|
const auto parsingModeString = parseResult["parsing-mode"].as<std::string>();
|
||||||
|
|
||||||
if (parsingModeString == "compatibility")
|
if (parsingModeString == "compatibility")
|
||||||
parsingMode = pddl::Mode::Compatibility;
|
parsingMode = pddl::Mode::Compatibility;
|
||||||
else if (parsingModeString != "strict")
|
else if (parsingModeString != "strict")
|
||||||
throw OptionException("unknown parsing mode “" + parsingModeString + "”");
|
throw OptionException("unknown parsing mode “" + parsingModeString + "”");
|
||||||
|
|
||||||
if (options.count("input"))
|
if (parseResult.count("input"))
|
||||||
inputFiles = options["input"].as<std::vector<std::string>>();
|
inputFiles = parseResult["input"].as<std::vector<std::string>>();
|
||||||
|
|
||||||
const auto languageName = options["language"].as<std::string>();
|
const auto languageName = parseResult["language"].as<std::string>();
|
||||||
language = plasp::Language::fromString(languageName);
|
language = plasp::Language::fromString(languageName);
|
||||||
|
|
||||||
if (language == plasp::Language::Type::Unknown)
|
if (language == plasp::Language::Type::Unknown)
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 0b7686949d01f6475cc13ba0693725aefb76fc0c
|
Subproject commit 8893afe13cc47dd0be4f25b5ae491e652c146098
|
Reference in New Issue
Block a user