src/CLIParser.h
branchv_0
changeset 2 e6294ba5017f
parent 1 ccaed729f8d3
equal deleted inserted replaced
1:ccaed729f8d3 2:e6294ba5017f
    37 		else throw relpipe::cli::RelpipeCLIException(L"Missing CLI argument" + (i > 0 ? (L" after " + arguments[i - 1]) : L""), relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    37 		else throw relpipe::cli::RelpipeCLIException(L"Missing CLI argument" + (i > 0 ? (L" after " + arguments[i - 1]) : L""), relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    38 	}
    38 	}
    39 
    39 
    40 public:
    40 public:
    41 
    41 
    42 	static const relpipe::common::type::StringX OPTION_ENDPOINT_URL;
    42 	static const relpipe::common::type::StringX OPTION_CONNECTION_STRING;
    43 
    43 
    44 	Configuration parse(const std::vector<relpipe::common::type::StringX>& arguments) {
    44 	Configuration parse(const std::vector<relpipe::common::type::StringX>& arguments) {
    45 		Configuration c;
    45 		Configuration c;
    46 
    46 
    47 		for (int i = 0; i < arguments.size();) {
    47 		for (int i = 0; i < arguments.size();) {
    48 			relpipe::common::type::StringX option = readNext(arguments, i);
    48 			relpipe::common::type::StringX option = readNext(arguments, i);
    49 
    49 
    50 			if (option == OPTION_ENDPOINT_URL) {
    50 			if (option == OPTION_CONNECTION_STRING) {
    51 				c.endpointUrl = readNext(arguments, i);
    51 				c.connectionString = readNext(arguments, i);
    52 			} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    52 			} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    53 		}
    53 		}
    54 
    54 
    55 		return c;
    55 		return c;
    56 	}
    56 	}
    57 
    57 
    58 	virtual ~CLIParser() {
    58 	virtual ~CLIParser() {
    59 	}
    59 	}
    60 };
    60 };
    61 
    61 
    62 const relpipe::common::type::StringX CLIParser::OPTION_ENDPOINT_URL = L"--endpoint-url";
    62 const relpipe::common::type::StringX CLIParser::OPTION_CONNECTION_STRING = L"--connection-string";
    63 
    63 
    64 }
    64 }
    65 }
    65 }
    66 }
    66 }