src/CLIParser.h
branchv_0
changeset 37 3de41719d7eb
parent 34 24c05e69d68f
child 47 428c278af4be
--- a/src/CLIParser.h	Sun May 31 16:56:07 2020 +0200
+++ b/src/CLIParser.h	Sun May 31 21:20:24 2020 +0200
@@ -52,8 +52,8 @@
 	static const string_t OPTION_PARAMETER;
 	static const string_t OPTION_COPY;
 	static const string_t OPTION_COPY_RENAMED;
-	static const string_t OPTION_FILE;
-	static const string_t OPTION_FILE_KEEP;
+	static const string_t OPTION_DATA_SOURCE_NAME;
+	static const string_t OPTION_DATA_SOURCE_URL;
 	static const string_t OPTION_LIST_DATA_SOURCES;
 
 	Configuration parse(const std::vector<string_t>& arguments) {
@@ -80,20 +80,18 @@
 				c.copyRelations.push_back({readNext(arguments, i), L"", false});
 			} else if (option == OPTION_COPY_RENAMED) {
 				c.copyRelations.push_back({readNext(arguments, i), readNext(arguments, i), true});
-			} else if (option == OPTION_FILE) {
-				c.file = readNext(arguments, i);
-			} else if (option == OPTION_FILE_KEEP) {
-				string_t value = readNext(arguments, i);
-				if (value == L"auto") c.keepFile = KeepFile::Automatic;
-				else if (value == L"true") c.keepFile = KeepFile::Always;
-				else if (value == L"false") c.keepFile = KeepFile::Never;
-				else throw relpipe::cli::RelpipeCLIException(L"Unsupported keep-file value: " + value + L" Expecting: true, false, auto", relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
+			} else if (option == OPTION_DATA_SOURCE_NAME) {
+				c.dataSourceName = readNext(arguments, i);
+			} else if (option == OPTION_DATA_SOURCE_URL) {
+				c.dataSourceURL = readNext(arguments, i);
 			} else if (option == OPTION_LIST_DATA_SOURCES) {
 				c.listDataSources = true;
 			} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
 		}
 		addQuery(c, currentQuery); // last relation
 
+		if (c.dataSourceName.size() && c.dataSourceURL.size()) throw relpipe::cli::RelpipeCLIException(L"Specify data source name or data source URL, not both.", relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
+
 		return c;
 	}
 
@@ -110,9 +108,9 @@
 const string_t CLIParser::OPTION_PARAMETER = L"--parameter";
 const string_t CLIParser::OPTION_COPY = L"--copy";
 const string_t CLIParser::OPTION_COPY_RENAMED = L"--copy-renamed";
-const string_t CLIParser::OPTION_FILE = L"--file";
-const string_t CLIParser::OPTION_FILE_KEEP = L"--file-keep";
 const string_t CLIParser::OPTION_LIST_DATA_SOURCES = L"--list-data-sources";
+const string_t CLIParser::OPTION_DATA_SOURCE_NAME = L"--data-source-name";
+const string_t CLIParser::OPTION_DATA_SOURCE_URL = L"--data-source-url";
 
 }
 }