src/CLIParser.h
branchv_0
changeset 5 cbc7817a3346
parent 2 362f2689cb87
child 10 7da7173d84b0
equal deleted inserted replaced
4:925b15fb5c63 5:cbc7817a3346
    48 
    48 
    49 public:
    49 public:
    50 
    50 
    51 	static const string_t OPTION_RELATION;
    51 	static const string_t OPTION_RELATION;
    52 	static const string_t OPTION_PARAMETER;
    52 	static const string_t OPTION_PARAMETER;
       
    53 	static const string_t OPTION_FILE;
       
    54 	static const string_t OPTION_KEEP_FILE;
    53 
    55 
    54 	Configuration parse(const std::vector<string_t>& arguments) {
    56 	Configuration parse(const std::vector<string_t>& arguments) {
    55 		Configuration c;
    57 		Configuration c;
    56 		Statement currentQuery;
    58 		Statement currentQuery;
    57 
    59 
    64 				currentQuery.sql = readNext(arguments, i);
    66 				currentQuery.sql = readNext(arguments, i);
    65 			} else if (option == OPTION_PARAMETER) {
    67 			} else if (option == OPTION_PARAMETER) {
    66 				Parameter parameter;
    68 				Parameter parameter;
    67 				parameter.value = readNext(arguments, i);
    69 				parameter.value = readNext(arguments, i);
    68 				currentQuery.parameters.push_back(parameter);
    70 				currentQuery.parameters.push_back(parameter);
       
    71 			} else if (option == OPTION_FILE) {
       
    72 				c.file = readNext(arguments, i);
       
    73 			} else if (option == OPTION_KEEP_FILE) {
       
    74 				c.keepFile = true;
    69 			} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    75 			} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    70 		}
    76 		}
    71 		addQuery(c, currentQuery); // last relation
    77 		addQuery(c, currentQuery); // last relation
    72 
    78 
    73 		return c;
    79 		return c;
    77 	}
    83 	}
    78 };
    84 };
    79 
    85 
    80 
    86 
    81 // relpipe-tr-sql --relation "tabulka" "SELECT * FROM fstab WHERE id = ?" --parameter "123"
    87 // relpipe-tr-sql --relation "tabulka" "SELECT * FROM fstab WHERE id = ?" --parameter "123"
    82 // TODO: --file db.sqlite --keep-file
       
    83 // TODO: --type string/integer/boolean (default is string)
    88 // TODO: --type string/integer/boolean (default is string)
    84 
    89 
    85 const string_t CLIParser::OPTION_RELATION = L"--relation";
    90 const string_t CLIParser::OPTION_RELATION = L"--relation";
    86 const string_t CLIParser::OPTION_PARAMETER = L"--parameter";
    91 const string_t CLIParser::OPTION_PARAMETER = L"--parameter";
       
    92 const string_t CLIParser::OPTION_FILE = L"--file";
       
    93 const string_t CLIParser::OPTION_KEEP_FILE = L"--keep-file";
    87 
    94 
    88 }
    95 }
    89 }
    96 }
    90 }
    97 }