Skip to content

Commit

Permalink
fix invalid command options for test program
Browse files Browse the repository at this point in the history
  • Loading branch information
sewenew committed May 9, 2019
1 parent fa9f454 commit a51b10c
Showing 1 changed file with 55 additions and 48 deletions.
103 changes: 55 additions & 48 deletions test/src/sw/redis++/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,55 +113,62 @@ auto parse_options(int argc, char **argv)

int opt = 0;
while ((opt = getopt(argc, argv, "h:p:a:n:c:k:v:r:t:bs:")) != -1) {
switch (opt) {
case 'h':
host = optarg;
break;

case 'p':
port = std::stoi(optarg);
break;

case 'a':
auth = optarg;
break;

case 'n':
cluster_node = optarg;
break;

case 'c':
cluster_port = std::stoi(optarg);
break;

case 'b':
benchmark = true;
break;

case 'k':
tmp_benchmark_opts.key_len = std::stoi(optarg);
break;

case 'v':
tmp_benchmark_opts.val_len = std::stoi(optarg);
break;

case 'r':
tmp_benchmark_opts.total_request_num = std::stoi(optarg);
break;

case 't':
tmp_benchmark_opts.thread_num = std::stoi(optarg);
break;

case 's':
tmp_benchmark_opts.pool_size = std::stoi(optarg);
break;

default:
try {
switch (opt) {
case 'h':
host = optarg;
break;

case 'p':
port = std::stoi(optarg);
break;

case 'a':
auth = optarg;
break;

case 'n':
cluster_node = optarg;
break;

case 'c':
cluster_port = std::stoi(optarg);
break;

case 'b':
benchmark = true;
break;

case 'k':
tmp_benchmark_opts.key_len = std::stoi(optarg);
break;

case 'v':
tmp_benchmark_opts.val_len = std::stoi(optarg);
break;

case 'r':
tmp_benchmark_opts.total_request_num = std::stoi(optarg);
break;

case 't':
tmp_benchmark_opts.thread_num = std::stoi(optarg);
break;

case 's':
tmp_benchmark_opts.pool_size = std::stoi(optarg);
break;

default:
throw sw::redis::Error("Unknow command line option");
break;
}
} catch (const sw::redis::Error &e) {
print_help();
throw;
} catch (const std::exception &e) {
print_help();
throw sw::redis::Error("Failed to parse connection options");
break;
throw sw::redis::Error("Invalid command line option");
}
}

Expand Down

0 comments on commit a51b10c

Please sign in to comment.