Improved command-line interface.
This commit is contained in:
parent
180cc33ded
commit
f4efb4f3d4
@ -5,6 +5,7 @@
|
||||
Features:
|
||||
|
||||
* extended PDDL support (`imply` expressions)
|
||||
* improved command-line interface
|
||||
|
||||
## 3.0.3 (2016-09-02)
|
||||
|
||||
|
@ -45,7 +45,7 @@ $ clingo encodings/sequential-incremental.lp instance.lp
|
||||
## Command-Line Interface
|
||||
|
||||
```bash
|
||||
$ plasp [files] [options]
|
||||
$ plasp [options] file...
|
||||
```
|
||||
|
||||
`plasp` automatically detects the language of the input program.
|
||||
|
@ -20,4 +20,4 @@ set(libraries
|
||||
|
||||
add_executable(${target} ${sources})
|
||||
target_link_libraries(${target} ${libraries})
|
||||
set_target_properties(plasp_app PROPERTIES OUTPUT_NAME plasp)
|
||||
set_target_properties(${target} PROPERTIES OUTPUT_NAME plasp)
|
||||
|
@ -18,12 +18,12 @@ int main(int argc, char **argv)
|
||||
|
||||
po::options_description description("Allowed options");
|
||||
description.add_options()
|
||||
("help,h", "Display this help message.")
|
||||
("version,v", "Display version information.")
|
||||
("input,i", po::value<std::vector<std::string>>(), "Specify the PDDL or SAS input file.")
|
||||
("language,l", po::value<std::string>(), "Specify the input language (sas or pddl). Omit for automatic detection.")
|
||||
("warning-level", po::value<std::string>()->default_value("normal"), "Specify whether to output warnings normally (normal), to treat them as critical errors (error), or to ignore them (ignore).")
|
||||
("color", po::value<std::string>()->default_value("auto"), "Specify whether to colorize the output (always, never, or auto).");
|
||||
("help,h", "Display this help message")
|
||||
("version,v", "Display version information")
|
||||
("input,i", po::value<std::vector<std::string>>(), "Input files (in PDDL or SAS format)")
|
||||
("language,l", po::value<std::string>()->default_value("auto"), "Input language (pddl, sas, auto)")
|
||||
("warning-level", po::value<std::string>()->default_value("show"), "Show warnings (show), treat them as errors (error), or ignore them (ignore)")
|
||||
("color", po::value<std::string>()->default_value("auto"), "Colorize output (always, never, auto)");
|
||||
|
||||
po::positional_options_description positionalOptionsDescription;
|
||||
positionalOptionsDescription.add("input", -1);
|
||||
@ -33,8 +33,8 @@ int main(int argc, char **argv)
|
||||
const auto printHelp =
|
||||
[&]()
|
||||
{
|
||||
std::cout << "Usage: plasp [files] [options]" << std::endl;
|
||||
std::cout << "Translate PDDL instances to ASP facts." << std::endl << std::endl;
|
||||
std::cout << "Usage: plasp [options] file..." << std::endl;
|
||||
std::cout << "Translate PDDL to ASP." << std::endl << std::endl;
|
||||
|
||||
std::cout << description;
|
||||
};
|
||||
@ -76,8 +76,8 @@ int main(int argc, char **argv)
|
||||
logger.setWarningLevel(plasp::utils::Logger::WarningLevel::Error);
|
||||
else if (warningLevel == "ignore")
|
||||
logger.setWarningLevel(plasp::utils::Logger::WarningLevel::Ignore);
|
||||
else if (warningLevel == "normal")
|
||||
logger.setWarningLevel(plasp::utils::Logger::WarningLevel::Normal);
|
||||
else if (warningLevel == "show")
|
||||
logger.setWarningLevel(plasp::utils::Logger::WarningLevel::Show);
|
||||
else
|
||||
{
|
||||
logger.logError("unknown warning level “" + warningLevel + "”");
|
||||
@ -122,12 +122,13 @@ int main(int argc, char **argv)
|
||||
const auto detectLanguage =
|
||||
[&]()
|
||||
{
|
||||
if (variablesMap.count("language") == 0)
|
||||
const auto languageName = variablesMap["language"].as<std::string>();
|
||||
const auto language = plasp::Language::fromString(languageName);
|
||||
|
||||
if (language == plasp::Language::Type::Automatic)
|
||||
return plasp::detectLanguage(parser);
|
||||
|
||||
const auto languageName = variablesMap["language"].as<std::string>();
|
||||
|
||||
return plasp::Language::fromString(languageName);
|
||||
return language;
|
||||
};
|
||||
|
||||
const auto language = detectLanguage();
|
||||
|
@ -1,18 +1,18 @@
|
||||
# Command-Line Interface
|
||||
|
||||
```bash
|
||||
$ plasp [files] [options]
|
||||
$ plasp [options] file...
|
||||
```
|
||||
|
||||
`plasp` automatically detects the language of the input files.
|
||||
|
||||
Multiple files may be provided in an arbitrary order.
|
||||
`[files]` may also be omitted, in which case the input is read from `std::cin`.
|
||||
The `file...` arguments may also be omitted, in which case the input is read from `std::cin`.
|
||||
|
||||
`plasp` supports the following options:
|
||||
|
||||
| **option** | **explanation** |
|
||||
|-----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `-l` [ `--language` ] | Specify the input language (`sas` or `pddl`). Omit for automatic detection. |
|
||||
| `--warning-level` arg (=`normal`) | Specify whether to output warnings normally (`normal`), to treat them as critical errors (`error`), or to ignore them (`ignore`). |
|
||||
| `--color` arg (=`auto`) | Specify whether to colorize the output (`always`, `never`, or `auto`). |
|
||||
|------------|-----------------|
|
||||
| `-l` [ `--language` ] arg (=`auto`) | Input language (`pddl`, `sas`, `auto`) |
|
||||
| `--warning-level` arg (=`show`) | Show warnings (`show`), treat them as errors (`error`), or ignore them (`ignore`) |
|
||||
| `--color` arg (=`auto`) | Colorize output (`always`, `never`, `auto`) |
|
||||
|
@ -18,6 +18,7 @@ class Language
|
||||
enum class Type
|
||||
{
|
||||
Unknown,
|
||||
Automatic,
|
||||
PDDL,
|
||||
SAS
|
||||
};
|
||||
|
@ -23,7 +23,7 @@ class Logger
|
||||
public:
|
||||
enum class WarningLevel
|
||||
{
|
||||
Normal,
|
||||
Show,
|
||||
Error,
|
||||
Ignore
|
||||
};
|
||||
|
@ -17,6 +17,7 @@ using LanguageNames = boost::bimap<Language::Type, std::string>;
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const LanguageNames languageNames = boost::assign::list_of<LanguageNames::relation>
|
||||
(Language::Type::Automatic, "auto")
|
||||
(Language::Type::PDDL, "pddl")
|
||||
(Language::Type::SAS, "sas")
|
||||
(Language::Type::Unknown, "unknown");
|
||||
|
@ -16,7 +16,7 @@ namespace utils
|
||||
Logger::Logger()
|
||||
: m_outputStream(StandardStream::Out),
|
||||
m_errorStream(StandardStream::Err),
|
||||
m_warningLevel{Logger::WarningLevel::Normal}
|
||||
m_warningLevel{Logger::WarningLevel::Show}
|
||||
{
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ Logger::Logger(Logger &&other)
|
||||
m_errorStream{std::move(other.m_errorStream)},
|
||||
m_warningLevel{other.m_warningLevel}
|
||||
{
|
||||
other.m_warningLevel = WarningLevel::Normal;
|
||||
other.m_warningLevel = WarningLevel::Show;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -58,7 +58,7 @@ Logger &Logger::operator=(Logger &&other)
|
||||
m_errorStream = std::move(other.m_errorStream);
|
||||
m_warningLevel = other.m_warningLevel;
|
||||
|
||||
other.m_warningLevel = WarningLevel::Normal;
|
||||
other.m_warningLevel = WarningLevel::Show;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
Reference in New Issue
Block a user