src/CLIParser.h
branchv_0
changeset 5 dbf093b8b9ac
parent 0 17fc678e0a94
equal deleted inserted replaced
4:e5baa07d6e60 5:dbf093b8b9ac
    46 		else throw relpipe::cli::RelpipeCLIException(L"Unable to parse boolean value: " + value + L" (expecting true or false)", relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    46 		else throw relpipe::cli::RelpipeCLIException(L"Unable to parse boolean value: " + value + L" (expecting true or false)", relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    47 	}
    47 	}
    48 
    48 
    49 public:
    49 public:
    50 
    50 
    51 	static const relpipe::reader::string_t OPTION_WRITE_HEADER;
    51 	static const relpipe::reader::string_t OPTION_DEBUG;
       
    52 	static const relpipe::reader::string_t OPTION_DRY_RUN;
    52 
    53 
    53 	Configuration parse(const std::vector<relpipe::reader::string_t>& arguments) {
    54 	Configuration parse(const std::vector<relpipe::reader::string_t>& arguments) {
    54 		Configuration c;
    55 		Configuration c;
    55 
    56 
    56 		for (int i = 0; i < arguments.size();) {
    57 		for (int i = 0; i < arguments.size();) {
    57 			relpipe::reader::string_t option = readNext(arguments, i);
    58 			relpipe::reader::string_t option = readNext(arguments, i);
    58 
    59 
    59 			if (option == OPTION_WRITE_HEADER) {
    60 			if (option == OPTION_DEBUG) {
    60 				c.writeHeader = parseBoolean(readNext(arguments, i));
    61 				c.debug = parseBoolean(readNext(arguments, i));
       
    62 			} else if (option == OPTION_DRY_RUN) {
       
    63 				c.dryRun = parseBoolean(readNext(arguments, i));
    61 			} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    64 			} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    62 		}
    65 		}
    63 
    66 
    64 		return c;
    67 		return c;
    65 	}
    68 	}
    66 
    69 
    67 	virtual ~CLIParser() {
    70 	virtual ~CLIParser() {
    68 	}
    71 	}
    69 };
    72 };
    70 
    73 
    71 const relpipe::reader::string_t CLIParser::OPTION_WRITE_HEADER = L"--write-header";
    74 const relpipe::reader::string_t CLIParser::OPTION_DEBUG = L"--debug";
       
    75 const relpipe::reader::string_t CLIParser::OPTION_DRY_RUN = L"--dry-run";
    72 
    76 
    73 }
    77 }
    74 }
    78 }
    75 }
    79 }