diff -r e8205d9206fb -r 291bdd97fcff src/CLIParser.h --- a/src/CLIParser.h Sat Feb 26 01:21:14 2022 +0100 +++ b/src/CLIParser.h Tue Mar 01 00:47:49 2022 +0100 @@ -37,38 +37,11 @@ else throw relpipe::cli::RelpipeCLIException(L"Missing CLI argument" + (i > 0 ? (L" after " + arguments[i - 1]) : L""), relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS); } - /** - * TODO: use a common method - */ - bool parseBoolean(const relpipe::writer::string_t& value) { - if (value == L"true") return true; - else if (value == L"false") return false; - else throw relpipe::cli::RelpipeCLIException(L"Unable to parse boolean value: " + value + L" (expecting true or false)", relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS); - } - - /** - * TODO: use a common method - */ - relpipe::writer::TypeId parseTypeId(const relpipe::writer::string_t& value) { - using t = relpipe::writer::TypeId; - if (value == L"string") return t::STRING; - else if (value == L"integer") return t::INTEGER; - else if (value == L"boolean") return t::BOOLEAN; - else throw relpipe::cli::RelpipeCLIException(L"Unable to parse TypeId: " + value, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS); - } - - Configuration::ReadTypes parseReadTypes(const relpipe::writer::string_t& value) { - if (value == L"auto") return Configuration::ReadTypes::AUTO; - else if (value == L"true") return Configuration::ReadTypes::TRUE; - else if (value == L"false") return Configuration::ReadTypes::FALSE; - else throw relpipe::cli::RelpipeCLIException(L"Unable to parse ReadTypes: " + value, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS); - } - public: static const relpipe::writer::string_t OPTION_RELATION; - static const relpipe::writer::string_t OPTION_ATTRIBUTE; - static const relpipe::writer::string_t OPTION_READ_TYPES; + static const relpipe::writer::string_t OPTION_QUEUE; + static const relpipe::writer::string_t OPTION_MESSAGE_COUNT; Configuration parse(const std::vector& arguments) { Configuration c; @@ -78,13 +51,10 @@ if (option == OPTION_RELATION) { c.relation = readNext(arguments, i); - } else if (option == OPTION_ATTRIBUTE) { - AttributeRecipe attribute; - attribute.name = readNext(arguments, i); - attribute.type = parseTypeId(readNext(arguments, i)); - c.attributes.push_back(attribute); - } else if (option == OPTION_READ_TYPES) { - c.readTypes = parseReadTypes(readNext(arguments, i)); + } else if (option == OPTION_QUEUE) { + c.queue = readNext(arguments, i); + } else if (option == OPTION_MESSAGE_COUNT) { + c.messageCount = std::stoull(readNext(arguments, i)); } else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS); } @@ -96,8 +66,8 @@ }; const relpipe::writer::string_t CLIParser::OPTION_RELATION = L"--relation"; -const relpipe::writer::string_t CLIParser::OPTION_ATTRIBUTE = L"--attribute"; -const relpipe::writer::string_t CLIParser::OPTION_READ_TYPES = L"--read-types"; +const relpipe::writer::string_t CLIParser::OPTION_QUEUE = L"--queue"; +const relpipe::writer::string_t CLIParser::OPTION_MESSAGE_COUNT = L"--message-count"; } }