# HG changeset patch # User František Kučera # Date 1572347378 -3600 # Node ID 0c050899c77f491367784ea677657f9e6ff3fc1f # Parent 3bcb28cbf655308bd3b6ea47311d5bc3b9d48940 add --where option: similar to --for-each but better expresses the intention: filtering The --for-each is more universal and can be used for both transformations and filtering. diff -r 3bcb28cbf655 -r 0c050899c77f bash-completion.sh --- a/bash-completion.sh Sun Oct 27 19:49:22 2019 +0100 +++ b/bash-completion.sh Tue Oct 29 12:09:38 2019 +0100 @@ -35,7 +35,8 @@ elif [[ "$w1" == "--define" && "x$w0" == "x" ]]; then COMPREPLY=("''") elif [[ "$w2" == "--define" ]]; then COMPREPLY=($(compgen -W "${DATA_TYPE[*]}" -- "$w0")) elif [[ "$w3" == "--define" && "x$w0" == "x" ]]; then COMPREPLY=("''") - elif [[ "$w1" == "--for-each" && "x$w0" == "x" ]]; then COMPREPLY=("'1'") + elif [[ "$w1" == "--for-each" && "x$w0" == "x" ]]; then COMPREPLY=("'(a == \"abc\") { a = \"X\"; record(); }'") + elif [[ "$w1" == "--where" && "x$w0" == "x" ]]; then COMPREPLY=("'a == \"abc\" || b = 123'") else OPTIONS=( "--relation" @@ -46,6 +47,7 @@ "--before-records" "--after-records" "--for-each" + "--where" "--drop" "--define" ) diff -r 3bcb28cbf655 -r 0c050899c77f src/CLIParser.h --- a/src/CLIParser.h Sun Oct 27 19:49:22 2019 +0100 +++ b/src/CLIParser.h Tue Oct 29 12:09:38 2019 +0100 @@ -67,6 +67,7 @@ static const string_t OPTION_BEFORE_RECORDS; static const string_t OPTION_AFTER_RECORDS; static const string_t OPTION_FOR_EACH; + static const string_t OPTION_WHERE; static const string_t OPTION_DROP; static const string_t OPTION_DEFINE; @@ -80,6 +81,7 @@ if (option == OPTION_BEFORE_RECORDS) currentRelation.awkBeforeRecords = readNext(arguments, i); else if (option == OPTION_AFTER_RECORDS) currentRelation.awkAfterRecords = readNext(arguments, i); else if (option == OPTION_FOR_EACH) currentRelation.awkForEach = readNext(arguments, i); + else if (option == OPTION_WHERE) currentRelation.awkForEach = L"(" + readNext(arguments, i) + L")"; else if (option == OPTION_DROP) currentRelation.drop = true; else if (option == OPTION_INPUT_ATTRIBUTES_APPEND) currentRelation.inputAttributesAppend = true; else if (option == OPTION_INPUT_ATTRIBUTES_PREPEND) currentRelation.inputAttributesPrepend = true; @@ -118,6 +120,7 @@ const string_t CLIParser::OPTION_BEFORE_RECORDS = L"--before-records"; const string_t CLIParser::OPTION_AFTER_RECORDS = L"--after-records"; const string_t CLIParser::OPTION_FOR_EACH = L"--for-each"; +const string_t CLIParser::OPTION_WHERE = L"--where"; const string_t CLIParser::OPTION_DROP = L"--drop"; const string_t CLIParser::OPTION_DEFINE = L"--define";