# HG changeset patch # User František Kučera # Date 1602081757 -7200 # Node ID c22577615ce458f5fd524dda6e15bc73b1e825ef # Parent 3c6374467a82b502851373212052dd3a2e181e03 rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count „write“ is more generic and can be used consistently across various output modules diff -r 3c6374467a82 -r c22577615ce4 bash-completion.sh --- a/bash-completion.sh Thu Sep 24 18:57:20 2020 +0200 +++ b/bash-completion.sh Wed Oct 07 16:42:37 2020 +0200 @@ -28,15 +28,15 @@ ) if [[ "$w1" == "--relation" && "x$w0" == "x" ]]; then COMPREPLY=("'.+'") - elif [[ "$w1" == "--print-types" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) - elif [[ "$w1" == "--print-relation-name" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) - elif [[ "$w1" == "--print-record-count" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) + elif [[ "$w1" == "--write-types" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) + elif [[ "$w1" == "--write-relation-name" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) + elif [[ "$w1" == "--write-record-count" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) else OPTIONS=( "--relation" - "--print-types" - "--print-relation-name" - "--print-record-count" + "--write-types" + "--write-relation-name" + "--write-record-count" ) COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0")) fi diff -r 3c6374467a82 -r c22577615ce4 src/CLIParser.h --- a/src/CLIParser.h Thu Sep 24 18:57:20 2020 +0200 +++ b/src/CLIParser.h Wed Oct 07 16:42:37 2020 +0200 @@ -42,9 +42,9 @@ c.relationConfigurations.push_back(currentRelation); } else { // no relation name given → global configuration - c.printTypes = currentRelation.printTypes; - c.printRelationName = currentRelation.printRelationName; - c.printRecordCount = currentRelation.printRecordCount; + c.writeTypes = currentRelation.writeTypes; + c.writeRelationName = currentRelation.writeRelationName; + c.writeRecordCount = currentRelation.writeRecordCount; } currentRelation = RelationConfiguration(); } @@ -61,9 +61,9 @@ public: static const relpipe::reader::string_t OPTION_RELATION; - static const relpipe::reader::string_t OPTION_PRINT_TYPES; - static const relpipe::reader::string_t OPTION_PRINT_RELATION_NAME; - static const relpipe::reader::string_t OPTION_PRINT_RECORD_COUNT; + 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; Configuration parse(const std::vector& arguments) { Configuration c; @@ -75,12 +75,12 @@ if (option == OPTION_RELATION) { addRelation(c, currentRelation); // previous relation currentRelation.relation = readNext(arguments, i); - } else if (option == OPTION_PRINT_TYPES) { - currentRelation.printTypes = parseBoolean(readNext(arguments, i)); - } else if (option == OPTION_PRINT_RELATION_NAME) { - currentRelation.printRelationName = parseBoolean(readNext(arguments, i)); - } else if (option == OPTION_PRINT_RECORD_COUNT) { - currentRelation.printRecordCount = parseBoolean(readNext(arguments, i)); + } else if (option == OPTION_WRITE_TYPES) { + currentRelation.writeTypes = parseBoolean(readNext(arguments, i)); + } else if (option == OPTION_WRITE_RELATION_NAME) { + currentRelation.writeRelationName = parseBoolean(readNext(arguments, i)); + } else if (option == OPTION_WRITE_RECORD_COUNT) { + currentRelation.writeRecordCount = parseBoolean(readNext(arguments, i)); } else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS); } @@ -94,9 +94,9 @@ }; const relpipe::reader::string_t CLIParser::OPTION_RELATION = L"--relation"; -const relpipe::reader::string_t CLIParser::OPTION_PRINT_TYPES = L"--print-types"; -const relpipe::reader::string_t CLIParser::OPTION_PRINT_RELATION_NAME = L"--print-relation-name"; -const relpipe::reader::string_t CLIParser::OPTION_PRINT_RECORD_COUNT = L"--print-record-count"; +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"; } } diff -r 3c6374467a82 -r c22577615ce4 src/Configuration.h --- a/src/Configuration.h Thu Sep 24 18:57:20 2020 +0200 +++ b/src/Configuration.h Wed Oct 07 16:42:37 2020 +0200 @@ -33,16 +33,16 @@ } relpipe::reader::string_t relation; - relpipe::reader::boolean_t printTypes = true; - relpipe::reader::boolean_t printRecordCount = true; - relpipe::reader::boolean_t printRelationName = true; + relpipe::reader::boolean_t writeTypes = true; + relpipe::reader::boolean_t writeRecordCount = true; + relpipe::reader::boolean_t writeRelationName = true; }; class Configuration { public: - relpipe::reader::boolean_t printTypes = true; - relpipe::reader::boolean_t printRecordCount = true; - relpipe::reader::boolean_t printRelationName = true; + relpipe::reader::boolean_t writeTypes = true; + relpipe::reader::boolean_t writeRecordCount = true; + relpipe::reader::boolean_t writeRelationName = true; std::vector relationConfigurations; virtual ~Configuration() { diff -r 3c6374467a82 -r c22577615ce4 src/TabularPrefetchingHandler.h --- a/src/TabularPrefetchingHandler.h Thu Sep 24 18:57:20 2020 +0200 +++ b/src/TabularPrefetchingHandler.h Wed Oct 07 16:42:37 2020 +0200 @@ -152,7 +152,7 @@ for (size_t i = 0; i < columnCount; i++) { string_t typeCode = columnTypeCodes[i]; string_t columnName = columnNames[i]; - integer_t minWidth = columnName.size() + (getConfiguration(printTypes) ? typeCode.size() + 3 : 0); // 3 = " ()" in "columnName (typeCode)" + integer_t minWidth = columnName.size() + (getConfiguration(writeTypes) ? typeCode.size() + 3 : 0); // 3 = " ()" in "columnName (typeCode)" columnWidths[i] = max(columnWidths[i], minWidth); paddings[i] = columnWidths[i] - minWidth; } @@ -166,7 +166,7 @@ for (integer_t p = 0; p < paddings[i]; p++) { output << " "; } - if (getConfiguration(printTypes)) output << " (" << convertor.to_bytes(columnTypeCodes[i]) << ")"; + if (getConfiguration(writeTypes)) output << " (" << convertor.to_bytes(columnTypeCodes[i]) << ")"; output << ESC_BORDER << " │" << ESC_RESET; } output << std::endl; @@ -189,7 +189,7 @@ } printHorizontalLine(L"╰", L"┴", L"╯"); - if (getConfiguration(printRecordCount)) { + if (getConfiguration(writeRecordCount)) { integer_t recordCount = values.size() / columnCount; output << ESC_YELLOW << "Record count: " << ESC_RESET << recordCount << std::endl; } @@ -213,7 +213,7 @@ } } - if (getConfiguration(printRelationName)) output << ESC_RED << convertor.to_bytes(name) << ":" << ESC_RESET << endl; + if (getConfiguration(writeRelationName)) output << ESC_RED << convertor.to_bytes(name) << ":" << ESC_RESET << endl; columnCount = attributes.size(); columnTypes.resize(columnCount); columnTypeCodes.resize(columnCount);