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>();
|
auto format = variablesMap["format"].as<std::string>();
|
||||||
std::transform(format.begin(), format.end(), format.begin(), ::tolower);
|
std::transform(format.begin(), format.end(), format.begin(), ::tolower);
|
||||||
|
|
||||||
const auto &inputFiles = variablesMap["input"].as<std::vector<std::string>>();
|
|
||||||
|
|
||||||
if (format == "sas")
|
if (format == "sas")
|
||||||
{
|
{
|
||||||
|
if (variablesMap.count("input"))
|
||||||
|
{
|
||||||
|
const auto &inputFiles = variablesMap["input"].as<std::vector<std::string>>();
|
||||||
|
|
||||||
if (inputFiles.size() > 1)
|
if (inputFiles.size() > 1)
|
||||||
{
|
{
|
||||||
std::cerr << "Error: Only one input file allowed for SAS translation" << std::endl;
|
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;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto sasDescription = variablesMap.count("input")
|
const auto sasDescription = plasp::sas::Description::fromFile(inputFiles.front());
|
||||||
? plasp::sas::Description::fromFile(inputFiles.front())
|
|
||||||
: plasp::sas::Description::fromStream(std::cin);
|
|
||||||
const auto sasTranslator = plasp::sas::TranslatorASP(sasDescription);
|
const auto sasTranslator = plasp::sas::TranslatorASP(sasDescription);
|
||||||
sasTranslator.translate(std::cout);
|
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")
|
else if (format == "pddl")
|
||||||
{
|
{
|
||||||
const auto pddlDescription = variablesMap.count("input")
|
if (variablesMap.count("input"))
|
||||||
? plasp::pddl::Description::fromFiles(inputFiles)
|
{
|
||||||
: plasp::pddl::Description::fromStream(std::cin);
|
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;
|
//std::cout << pddlDescription << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user