Refactored printing help messages in commands.
This commit is contained in:
@@ -35,6 +35,23 @@ class Command
|
||||
});
|
||||
}
|
||||
|
||||
void printHelp(cxxopts::Options &options)
|
||||
{
|
||||
const auto numberOfOptionGroups = std::tuple_size<std::decay_t<decltype(m_optionGroups)>>();
|
||||
|
||||
std::vector<std::string> optionGroupNames;
|
||||
optionGroupNames.reserve(numberOfOptionGroups + 1);
|
||||
optionGroupNames.emplace_back("");
|
||||
|
||||
forEach(m_optionGroups,
|
||||
[&](auto &optionGroup)
|
||||
{
|
||||
optionGroupNames.emplace_back(optionGroup.Name);
|
||||
});
|
||||
|
||||
std::cout << options.help(optionGroupNames) << std::endl;
|
||||
}
|
||||
|
||||
std::tuple<OptionGroups...> m_optionGroups;
|
||||
};
|
||||
|
||||
|
@@ -27,6 +27,8 @@ class OptionException : public pddl::Exception
|
||||
|
||||
struct OptionGroupBasic
|
||||
{
|
||||
static constexpr const auto Name = "basic";
|
||||
|
||||
void addTo(cxxopts::Options &options);
|
||||
void parse(cxxopts::Options &options);
|
||||
|
||||
@@ -39,6 +41,8 @@ struct OptionGroupBasic
|
||||
|
||||
struct OptionGroupOutput
|
||||
{
|
||||
static constexpr const auto Name = "output";
|
||||
|
||||
void addTo(cxxopts::Options &options);
|
||||
void parse(cxxopts::Options &options);
|
||||
|
||||
@@ -50,6 +54,8 @@ struct OptionGroupOutput
|
||||
|
||||
struct OptionGroupParser
|
||||
{
|
||||
static constexpr const auto Name = "parser";
|
||||
|
||||
void addTo(cxxopts::Options &options);
|
||||
void parse(cxxopts::Options &options);
|
||||
|
||||
|
Reference in New Issue
Block a user