@@ -8,38 +8,30 @@ namespace cest
88{
99 CommandLineOptions parseArgs (int argc, const char *argv[])
1010 {
11- CommandLineOptions options = {0 };
11+ CommandLineOptions options;
12+ std::map<std::string, std::function<void ()>> parseSingle = {
13+ {" --help" , [&]() { options.help = true ; }},
14+ {" -h" , [&]() { options.help = true ; }},
15+ {" --randomize" , [&]() { options.randomize = true ; }},
16+ {" -r" , [&]() { options.randomize = true ; }},
17+ {" --json" , [&]() { options.json_output = true ; }},
18+ {" -j" , [&]() { options.json_output = true ; }},
19+ {" --only-suite-result" , [&]() { options.only_test_suite_result = true ; }},
20+ {" -o" , [&]() { options.only_test_suite_result = true ; }},
21+ {" --tree-suite-result" , [&]() { options.only_test_suite_result = true ; }},
22+ {" -t" , [&]() { options.tree_test_suite_result = true ; }}
23+ };
1224
1325 if (argc > 1 )
1426 {
1527 for (int i = 0 ; i < argc; ++i)
1628 {
17- if (strcmp (argv[i], " --help" ) == 0 || strcmp (argv[i], " -h" ) == 0 )
18- {
19- options.help = true ;
20- }
29+ const auto arg = std::string (argv[i]);
2130
22- if (strcmp (argv[i], " -r" ) == 0 || strcmp (argv[i], " --randomize" ) == 0 )
23- {
24- options.randomize = true ;
25- }
26-
27- if (strcmp (argv[i], " -j" ) == 0 || strcmp (argv[i], " --json" ) == 0 )
28- {
29- options.json_output = true ;
30- }
31-
32- if (strcmp (argv[i], " -o" ) == 0 || strcmp (argv[i], " --only-suite-result" ) == 0 )
33- {
34- options.only_test_suite_result = true ;
35- }
36-
37- if (strcmp (argv[i], " -t" ) == 0 || strcmp (argv[i], " --tree-suite-result" ) == 0 )
38- {
39- options.tree_test_suite_result = true ;
40- }
31+ if (parseSingle.contains (arg))
32+ parseSingle[arg]();
4133
42- if (strcmp (argv[i], " -s" ) == 0 || strcmp (argv[i], " --seed" ) == 0 )
34+ if (arg == " -s" || arg == " --seed" )
4335 {
4436 if (i + 1 < argc)
4537 {
0 commit comments