Refactored printing help messages in commands.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
|
||||
void OptionGroupBasic::addTo(cxxopts::Options &options)
|
||||
{
|
||||
options.add_options("basic")
|
||||
options.add_options(Name)
|
||||
("h,help", "Display this help message")
|
||||
("v,version", "Display version information")
|
||||
("warnings-as-errors", "Treat warnings as errors");
|
||||
@@ -27,7 +27,7 @@ void OptionGroupBasic::parse(cxxopts::Options &options)
|
||||
|
||||
void OptionGroupOutput::addTo(cxxopts::Options &options)
|
||||
{
|
||||
options.add_options("output")
|
||||
options.add_options(Name)
|
||||
("color", "Colorize output (always, never, auto)", cxxopts::value<std::string>()->default_value("auto"))
|
||||
("p,log-priority", "Log messages starting from this priority (debug, info, warning, error)", cxxopts::value<std::string>()->default_value("info"));
|
||||
}
|
||||
@@ -63,7 +63,7 @@ void OptionGroupOutput::parse(cxxopts::Options &options)
|
||||
|
||||
void OptionGroupParser::addTo(cxxopts::Options &options)
|
||||
{
|
||||
options.add_options("parser")
|
||||
options.add_options(Name)
|
||||
("i,input", "Input files (in PDDL or SAS format)", cxxopts::value<std::vector<std::string>>())
|
||||
("parsing-mode", "Parsing mode (strict, compatibility)", cxxopts::value<std::string>()->default_value("strict"))
|
||||
("l,language", "Input language (pddl, sas, auto)", cxxopts::value<std::string>()->default_value("auto"));
|
||||
|
@@ -37,15 +37,7 @@ int CommandTranslate::run(int argc, char **argv)
|
||||
cxxopts::Options options("plasp translate", "Translate PDDL to ASP.");
|
||||
|
||||
addOptionGroupsTo(options);
|
||||
|
||||
const auto printHelp =
|
||||
[&]()
|
||||
{
|
||||
std::cout << options.help({"", "basic", "output", "parser"});
|
||||
};
|
||||
|
||||
options.parse(argc, argv);
|
||||
|
||||
parseOptionGroups(options);
|
||||
|
||||
const auto &basicOptions = std::get<OptionGroupBasic>(m_optionGroups);
|
||||
@@ -54,7 +46,7 @@ int CommandTranslate::run(int argc, char **argv)
|
||||
|
||||
if (basicOptions.help)
|
||||
{
|
||||
printHelp();
|
||||
printHelp(options);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -110,7 +102,7 @@ int CommandTranslate::run(int argc, char **argv)
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, "unknown input language");
|
||||
std::cout << std::endl;
|
||||
printHelp();
|
||||
printHelp(options);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user