rename: --print-types, --print-relation-name, --print-record-count to --write-types, --write-relation-name, --write-record-count v_0 v0.17
authorFrantišek Kučera <franta-hg@frantovo.cz>
Wed, 07 Oct 2020 16:42:37 +0200
branchv_0
changeset 31 c22577615ce4
parent 30 3c6374467a82
child 32 0b082065b120
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
bash-completion.sh
src/CLIParser.h
src/Configuration.h
src/TabularPrefetchingHandler.h
--- 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
--- 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<relpipe::reader::string_t>& 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";
 
 }
 }
--- 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<RelationConfiguration> relationConfigurations;
 
 	virtual ~Configuration() {
--- 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);