support custom relation name through --relation option v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sat, 19 Jan 2019 21:21:26 +0100
branchv_0
changeset 16 6180161335be
parent 15 e7f05d7c4336
child 17 87a7607d5def
support custom relation name through --relation option
src/CLIParser.h
src/Configuration.h
src/FilesystemCommand.h
--- a/src/CLIParser.h	Sat Jan 19 21:16:39 2019 +0100
+++ b/src/CLIParser.h	Sat Jan 19 21:21:26 2019 +0100
@@ -56,6 +56,7 @@
 	static const string_t OPTION_XATTR;
 	static const string_t OPTION_AS;
 	static const string_t OPTION_OPTION;
+	static const string_t OPTION_RELATION;
 
 	Configuration parse(const std::vector<string_t>& arguments) {
 		Configuration c;
@@ -78,6 +79,8 @@
 				} else if (option == OPTION_OPTION) {
 					currentOptions.push_back(readNext(arguments, i));
 					currentOptions.push_back(readNext(arguments, i));
+				} else if (option == OPTION_RELATION) {
+					c.relation = readNext(arguments, i);
 				} else {
 					throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
 				}
@@ -114,6 +117,7 @@
 const string_t CLIParser::OPTION_XATTR = L"--" + RequestedField::GROUP_XATTR;
 const string_t CLIParser::OPTION_AS = L"--as";
 const string_t CLIParser::OPTION_OPTION = L"--option";
+const string_t CLIParser::OPTION_RELATION = L"--relation";
 
 }
 }
--- a/src/Configuration.h	Sat Jan 19 21:16:39 2019 +0100
+++ b/src/Configuration.h	Sat Jan 19 21:21:26 2019 +0100
@@ -29,6 +29,7 @@
 
 class Configuration {
 public:
+	string_t relation;
 	std::vector<RequestedField> fields;
 
 	virtual ~Configuration() {
--- a/src/FilesystemCommand.h	Sat Jan 19 21:16:39 2019 +0100
+++ b/src/FilesystemCommand.h	Sat Jan 19 21:21:26 2019 +0100
@@ -82,7 +82,8 @@
 			else throw RelpipeWriterException(L"Unsupported field group: " + field.group);
 		}
 
-		writer->startRelation(L"filesystem", attributesMetadata, true);
+		string_t relationName = configuration.relation.empty() ? L"filesystem" : configuration.relation;
+		writer->startRelation(relationName, attributesMetadata, true);
 
 
 		for (std::stringstream originalName; readNext(input, originalName); reset(originalName)) {