Fixed accepting std::cin input when omitting input file arguments.
This commit is contained in:
parent
69ff84eecc
commit
a1b93624d6
@ -66,10 +66,12 @@ int main(int argc, char **argv)
|
||||
auto format = variablesMap["format"].as<std::string>();
|
||||
std::transform(format.begin(), format.end(), format.begin(), ::tolower);
|
||||
|
||||
const auto &inputFiles = variablesMap["input"].as<std::vector<std::string>>();
|
||||
|
||||
if (format == "sas")
|
||||
{
|
||||
if (variablesMap.count("input"))
|
||||
{
|
||||
const auto &inputFiles = variablesMap["input"].as<std::vector<std::string>>();
|
||||
|
||||
if (inputFiles.size() > 1)
|
||||
{
|
||||
std::cerr << "Error: Only one input file allowed for SAS translation" << std::endl;
|
||||
@ -77,17 +79,27 @@ int main(int argc, char **argv)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const auto sasDescription = variablesMap.count("input")
|
||||
? plasp::sas::Description::fromFile(inputFiles.front())
|
||||
: plasp::sas::Description::fromStream(std::cin);
|
||||
const auto sasDescription = plasp::sas::Description::fromFile(inputFiles.front());
|
||||
const auto sasTranslator = plasp::sas::TranslatorASP(sasDescription);
|
||||
sasTranslator.translate(std::cout);
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto sasDescription = plasp::sas::Description::fromStream(std::cin);
|
||||
const auto sasTranslator = plasp::sas::TranslatorASP(sasDescription);
|
||||
sasTranslator.translate(std::cout);
|
||||
}
|
||||
}
|
||||
else if (format == "pddl")
|
||||
{
|
||||
const auto pddlDescription = variablesMap.count("input")
|
||||
? plasp::pddl::Description::fromFiles(inputFiles)
|
||||
: plasp::pddl::Description::fromStream(std::cin);
|
||||
if (variablesMap.count("input"))
|
||||
{
|
||||
const auto &inputFiles = variablesMap["input"].as<std::vector<std::string>>();
|
||||
const auto pddlDescription = plasp::pddl::Description::fromFiles(inputFiles);
|
||||
}
|
||||
else
|
||||
const auto pddlDescription = plasp::pddl::Description::fromStream(std::cin);
|
||||
|
||||
//std::cout << pddlDescription << std::endl;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user