--- a/src/CLIParser.h Mon Jun 20 00:15:08 2022 +0200
+++ b/src/CLIParser.h Mon Jun 20 00:55:56 2022 +0200
@@ -57,6 +57,22 @@
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);
}
+
+ Configuration::ColorScheme parseColorScheme(const relpipe::reader::string_t& value) {
+ if (value == L"green-screen") return Configuration::ColorScheme::GreenScreen;
+ else if (value == L"monochrome") return Configuration::ColorScheme::Monochrome;
+ else if (value == L"midnight") return Configuration::ColorScheme::Midnight;
+ else throw relpipe::cli::RelpipeCLIException(L"Unable to parse ColorScheme value: " + value + L" (expecting green-screen, monochrome or midnight)", relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
+ }
+
+ Configuration::TableStyle parseTableStyle(const relpipe::reader::string_t& value) {
+ if (value == L"rounded") return Configuration::TableStyle::Rounded;
+ else if (value == L"sharp") return Configuration::TableStyle::Sharp;
+ else if (value == L"sharp-double") return Configuration::TableStyle::SharpDouble;
+ else if (value == L"horizontal-only") return Configuration::TableStyle::HorizontalOnly;
+ else if (value == L"ascii") return Configuration::TableStyle::Ascii;
+ else throw relpipe::cli::RelpipeCLIException(L"Unable to parse TableStyle value: " + value + L" (expecting rounded, sharp, ascii)", relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
+ }
public:
@@ -64,10 +80,14 @@
static const relpipe::reader::string_t OPTION_WRITE_TYPES;
static const relpipe::reader::string_t OPTION_WRITE_RELATION_NAME;
static const relpipe::reader::string_t OPTION_WRITE_RECORD_COUNT;
+ static const relpipe::reader::string_t OPTION_COLOR_SCHEME;
+ static const relpipe::reader::string_t OPTION_TABLE_STYLE;
Configuration parse(const std::vector<relpipe::reader::string_t>& arguments) {
Configuration c;
RelationConfiguration currentRelation;
+
+ // TODO: global configuration of writeTypes, writeRelationName, writeRecordCount
for (int i = 0; i < arguments.size();) {
relpipe::reader::string_t option = readNext(arguments, i);
@@ -81,6 +101,10 @@
currentRelation.writeRelationName = parseBoolean(readNext(arguments, i));
} else if (option == OPTION_WRITE_RECORD_COUNT) {
currentRelation.writeRecordCount = parseBoolean(readNext(arguments, i));
+ } else if (option == OPTION_COLOR_SCHEME) {
+ c.colorScheme = parseColorScheme(readNext(arguments, i));
+ } else if (option == OPTION_TABLE_STYLE) {
+ c.tableStyle = parseTableStyle(readNext(arguments, i));
} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
}
@@ -97,6 +121,8 @@
const relpipe::reader::string_t CLIParser::OPTION_WRITE_TYPES = L"--write-types";
const relpipe::reader::string_t CLIParser::OPTION_WRITE_RELATION_NAME = L"--write-relation-name";
const relpipe::reader::string_t CLIParser::OPTION_WRITE_RECORD_COUNT = L"--write-record-count";
+const relpipe::reader::string_t CLIParser::OPTION_COLOR_SCHEME = L"--color-scheme";
+const relpipe::reader::string_t CLIParser::OPTION_TABLE_STYLE = L"--table-style";
}
}