# HG changeset patch # User František Kučera # Date 1549365298 -3600 # Node ID c9fece435aa2c36a0039d5c916b94c3d7ef9ed97 # Parent 7977c1bdba1f473c626aa6f23aeac86319e9b2f2 add --define for global variables (can be overridden by relation's ones) diff -r 7977c1bdba1f -r c9fece435aa2 src/CLIParser.h --- a/src/CLIParser.h Tue Feb 05 00:06:44 2019 +0100 +++ b/src/CLIParser.h Tue Feb 05 12:14:58 2019 +0100 @@ -97,7 +97,8 @@ definition.name = readNext(arguments, i); definition.type = readNext(arguments, i); definition.value = readNext(arguments, i); - currentRelation.definitions.push_back(definition); + if (currentRelation.relation.size()) currentRelation.definitions.push_back(definition); + else c.definitions.push_back(definition); } else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS); } diff -r 7977c1bdba1f -r c9fece435aa2 src/Configuration.h --- a/src/Configuration.h Tue Feb 05 00:06:44 2019 +0100 +++ b/src/Configuration.h Tue Feb 05 12:14:58 2019 +0100 @@ -56,6 +56,7 @@ /** * Variable definitions for this relation. * Can be used as a safe way for passing parameters from the outside environment. + * See also Configuration::definitions (can be overridden by relation's definitions) */ std::vector definitions; /** @@ -67,8 +68,13 @@ class Configuration { public: vector relationConfigurations; + /** + * Global definitions for all relations. + * Can be used as a safe way for passing parameters from the outside environment. + * See also RelationConfiguration::definitions + */ + std::vector definitions; - // TODO: --define – global definitions (for all relations)? // TODO: --relation … --drop – will execute --for-each, but no output will be generated for this relation // TODO: --create t2 3 a integer b boolean '…guile…' – allow creating new relations? Or allow calling startRelation() and attribute() from Guile? diff -r 7977c1bdba1f -r c9fece435aa2 src/GuileHandler.h --- a/src/GuileHandler.h Tue Feb 05 00:06:44 2019 +0100 +++ b/src/GuileHandler.h Tue Feb 05 12:14:58 2019 +0100 @@ -190,6 +190,8 @@ for (DefinitionRecipe definition : currentRelationConfiguration->definitions) undefineGuileVariable(definition.name); } for (auto attribute : currentReaderMetadata) undefineGuileVariable(attribute.getAttributeName()); + + for (DefinitionRecipe definition : configuration.definitions) defineGuileVariable(definition); currentRelationConfiguration = nullptr; for (int i = 0; i < configuration.relationConfigurations.size(); i++) {