# HG changeset patch # User František Kučera # Date 1600803134 -7200 # Node ID dd7094457e44adb69f318f388717baab7f7a7800 # Parent 3c8ea5dcf793d1d87acba9fd4f90c6d6df27159e add option: --write-header we can omit the relation's header and generate just the records and append them to an existing relational stream: (relpipe-in-cli --relation rrr --attribute a integer; relpipe-in-cli --write-header false --relation rrr --attribute XXX integer --records 1 2 3) | relpipe-out-tabular diff -r 3c8ea5dcf793 -r dd7094457e44 bash-completion.sh --- a/bash-completion.sh Tue Sep 22 21:00:30 2020 +0200 +++ b/bash-completion.sh Tue Sep 22 21:32:14 2020 +0200 @@ -28,12 +28,19 @@ "boolean" ) + WRITE_HEADER=( + "true" + "false" + ) + if [[ "$w1" == "--relation" && "x$w0" == "x" ]]; then COMPREPLY=("''") elif [[ "$w1" == "--attribute" && "x$w0" == "x" ]]; then COMPREPLY=("''") elif [[ "$w2" == "--attribute" ]]; then COMPREPLY=($(compgen -W "${DATA_TYPE[*]}" -- "$w0")) + elif [[ "$w1" == "--write-header" ]]; then COMPREPLY=($(compgen -W "${WRITE_HEADER[*]}" -- "$w0")) else OPTIONS=( "--relation" + "--write-header" "--attribute" "--record" "--records" diff -r 3c8ea5dcf793 -r dd7094457e44 src/CLICommand.h --- a/src/CLICommand.h Tue Sep 22 21:00:30 2020 +0200 +++ b/src/CLICommand.h Tue Sep 22 21:32:14 2020 +0200 @@ -35,7 +35,7 @@ // Write header / metadata: std::vector attributesMetadata; for (AttributeRecipe ar : configuration.attributes) attributesMetadata.push_back({ar.name, ar.type}); - writer->startRelation(configuration.relation, attributesMetadata, true); + writer->startRelation(configuration.relation, attributesMetadata, configuration.writeHeader); // Write records from CLI: for (auto value : configuration.values) writer->writeAttribute(value); diff -r 3c8ea5dcf793 -r dd7094457e44 src/CLIParser.h --- a/src/CLIParser.h Tue Sep 22 21:00:30 2020 +0200 +++ b/src/CLIParser.h Tue Sep 22 21:32:14 2020 +0200 @@ -71,6 +71,7 @@ public: static const relpipe::writer::string_t OPTION_RELATION; + static const relpipe::writer::string_t OPTION_WRITE_HEADER; static const relpipe::writer::string_t OPTION_ATTRIBUTE; static const relpipe::writer::string_t OPTION_RECORD; static const relpipe::writer::string_t OPTION_RECORDS; @@ -86,6 +87,8 @@ if (option == OPTION_RELATION) { addRelation(c, currentRelation); // previous relation currentRelation.relation = readNext(arguments, i); + } else if (option == OPTION_WRITE_HEADER) { + currentRelation.writeHeader = parseBoolean(readNext(arguments, i)); } else if (option == OPTION_ATTRIBUTE) { AttributeRecipe attribute; attribute.name = readNext(arguments, i); @@ -110,6 +113,7 @@ }; const relpipe::writer::string_t CLIParser::OPTION_RELATION = L"--relation"; +const relpipe::writer::string_t CLIParser::OPTION_WRITE_HEADER = L"--write-header"; const relpipe::writer::string_t CLIParser::OPTION_ATTRIBUTE = L"--attribute"; const relpipe::writer::string_t CLIParser::OPTION_RECORD = L"--record"; const relpipe::writer::string_t CLIParser::OPTION_RECORDS = L"--records"; diff -r 3c8ea5dcf793 -r dd7094457e44 src/Configuration.h --- a/src/Configuration.h Tue Sep 22 21:00:30 2020 +0200 +++ b/src/Configuration.h Tue Sep 22 21:32:14 2020 +0200 @@ -44,6 +44,7 @@ } relpipe::writer::string_t relation; + relpipe::writer::boolean_t writeHeader = true; std::vector attributes; std::vector values; std::istream* valueStream = nullptr;