| 9 | using namespace Bench; |
| 10 | |
| 11 | bool ArgumentParser::parse(int argc, ACE_TCHAR* argv[], OutputType& output_type, |
| 12 | OutputFormat& output_format, Bench::TestController::Report& report, std::shared_ptr<std::ostream>& output_stream, |
| 13 | ParseParameters& parse_parameters) |
| 14 | { |
| 15 | std::string input_file_path; |
| 16 | std::string output_file_path; |
| 17 | |
| 18 | if (argc == 1) { |
| 19 | show_usage_prompt(); |
| 20 | } else { |
| 21 | try { |
| 22 | for (int i = 1; i < argc; i++) { |
| 23 | const ACE_TCHAR* argument = argv[i]; |
| 24 | |
| 25 | if (!ACE_OS::strcmp(argument, ACE_TEXT("--help")) |
| 26 | || !ACE_OS::strcmp(argument, ACE_TEXT("-h"))) { |
| 27 | show_usage(); |
| 28 | return false; |
| 29 | } |
| 30 | |
| 31 | if (!ACE_OS::strcmp(argument, ACE_TEXT("--input-file"))) { |
| 32 | std::string option_argument = get_option_argument(i, argc, argv); |
| 33 | input_file_path = option_argument; |
| 34 | } else if (!ACE_OS::strcmp(argument, ACE_TEXT("--output-file"))) { |
| 35 | std::string option_argument = get_option_argument(i, argc, argv); |
| 36 | output_file_path = option_argument; |
| 37 | } else if (!ACE_OS::strcmp(argument, ACE_TEXT("--output-type"))) { |
| 38 | std::string option_argument = get_option_argument(i, argc, argv); |
| 39 | static std::unordered_map<std::string, OutputType> const table = { |
| 40 | { "single-statistic", OutputType::SingleStatistic }, |
| 41 | { "time-series", OutputType::TimeSeries }, |
| 42 | { "summary", OutputType::Summary } |
| 43 | }; |
| 44 | |
| 45 | auto it = table.find(option_argument); |
| 46 | |
| 47 | if (it != table.end()) { |
| 48 | output_type = it->second; |
| 49 | } else { |
| 50 | show_option_argument_error(option_argument); |
| 51 | return false; |
| 52 | } |
| 53 | } else if (!ACE_OS::strcmp(argument, ACE_TEXT("--output-format"))) { |
| 54 | std::string option_argument = get_option_argument(i, argc, argv); |
| 55 | static std::unordered_map<std::string, OutputFormat> const table = { |
| 56 | { "stat-block", OutputFormat::StatBlock }, |
| 57 | { "gnuplot", OutputFormat::Gnuplot }, |
| 58 | { "json", OutputFormat::Json } |
| 59 | }; |
| 60 | |
| 61 | auto it = table.find(option_argument); |
| 62 | |
| 63 | if (it != table.end()) { |
| 64 | output_format = it->second; |
| 65 | } else { |
| 66 | show_option_argument_error(option_argument); |
| 67 | return false; |
| 68 | } |
nothing calls this directly
no test coverage detected