Fixed accepting std::cin input when omitting input file arguments.

This commit is contained in:
Patrick Lühne 2016-06-08 00:06:54 +02:00
parent 69ff84eecc
commit a1b93624d6

View File

@ -66,28 +66,40 @@ 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 (inputFiles.size() > 1) if (variablesMap.count("input"))
{ {
std::cerr << "Error: Only one input file allowed for SAS translation" << std::endl; const auto &inputFiles = variablesMap["input"].as<std::vector<std::string>>();
printHelp();
return EXIT_FAILURE;
}
const auto sasDescription = variablesMap.count("input") if (inputFiles.size() > 1)
? plasp::sas::Description::fromFile(inputFiles.front()) {
: plasp::sas::Description::fromStream(std::cin); std::cerr << "Error: Only one input file allowed for SAS translation" << std::endl;
const auto sasTranslator = plasp::sas::TranslatorASP(sasDescription); printHelp();
sasTranslator.translate(std::cout); return EXIT_FAILURE;
}
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") 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;
} }
} }