src/CLIParser.h
branchv_0
changeset 16 3c51a2c32c86
parent 14 eacacf060755
child 17 b3c07fb178be
equal deleted inserted replaced
15:0ecde5272f8e 16:3c51a2c32c86
    47 
    47 
    48 public:
    48 public:
    49 
    49 
    50 	static const string_t OPTION_RELATION;
    50 	static const string_t OPTION_RELATION;
    51 	static const string_t OPTION_PARAMETER;
    51 	static const string_t OPTION_PARAMETER;
    52 	static const string_t OPTION_DUMP;
    52 	static const string_t OPTION_COPY;
       
    53 	static const string_t OPTION_COPY_RENAMED;
    53 	static const string_t OPTION_FILE;
    54 	static const string_t OPTION_FILE;
    54 	static const string_t OPTION_KEEP_FILE;
    55 	static const string_t OPTION_KEEP_FILE;
    55 
    56 
    56 	Configuration parse(const std::vector<string_t>& arguments) {
    57 	Configuration parse(const std::vector<string_t>& arguments) {
    57 		Configuration c;
    58 		Configuration c;
    66 				currentQuery.sql = readNext(arguments, i);
    67 				currentQuery.sql = readNext(arguments, i);
    67 			} else if (option == OPTION_PARAMETER) {
    68 			} else if (option == OPTION_PARAMETER) {
    68 				Parameter parameter;
    69 				Parameter parameter;
    69 				parameter.value = readNext(arguments, i);
    70 				parameter.value = readNext(arguments, i);
    70 				currentQuery.parameters.push_back(parameter);
    71 				currentQuery.parameters.push_back(parameter);
    71 			} else if (option == OPTION_DUMP) {
    72 			} else if (option == OPTION_COPY) {
    72 				c.dumpRelations = readNext(arguments, i);
    73 				c.copyRelations.push_back({readNext(arguments, i), L"", false});
       
    74 			} else if (option == OPTION_COPY_RENAMED) {
       
    75 				c.copyRelations.push_back({readNext(arguments, i), readNext(arguments, i), true});
    73 			} else if (option == OPTION_FILE) {
    76 			} else if (option == OPTION_FILE) {
    74 				c.file = readNext(arguments, i);
    77 				c.file = readNext(arguments, i);
    75 			} else if (option == OPTION_KEEP_FILE) {
    78 			} else if (option == OPTION_KEEP_FILE) {
    76 				string_t value = readNext(arguments, i);
    79 				string_t value = readNext(arguments, i);
    77 				if (value == L"auto") c.keepFile = KeepFile::Automatic;
    80 				if (value == L"auto") c.keepFile = KeepFile::Automatic;
    93 // relpipe-tr-sql --relation "tabulka" "SELECT * FROM fstab WHERE id = ?" --parameter "123"
    96 // relpipe-tr-sql --relation "tabulka" "SELECT * FROM fstab WHERE id = ?" --parameter "123"
    94 // TODO: --type string/integer/boolean (default is string)
    97 // TODO: --type string/integer/boolean (default is string)
    95 
    98 
    96 const string_t CLIParser::OPTION_RELATION = L"--relation";
    99 const string_t CLIParser::OPTION_RELATION = L"--relation";
    97 const string_t CLIParser::OPTION_PARAMETER = L"--parameter";
   100 const string_t CLIParser::OPTION_PARAMETER = L"--parameter";
    98 const string_t CLIParser::OPTION_DUMP = L"--dump";
   101 const string_t CLIParser::OPTION_COPY = L"--copy";
       
   102 const string_t CLIParser::OPTION_COPY_RENAMED = L"--copy-renamed";
    99 const string_t CLIParser::OPTION_FILE = L"--file";
   103 const string_t CLIParser::OPTION_FILE = L"--file";
   100 const string_t CLIParser::OPTION_KEEP_FILE = L"--keep-file";
   104 const string_t CLIParser::OPTION_KEEP_FILE = L"--keep-file";
   101 
   105 
   102 }
   106 }
   103 }
   107 }