File tree Expand file tree Collapse file tree 1 file changed +55
-48
lines changed Expand file tree Collapse file tree 1 file changed +55
-48
lines changed Original file line number Diff line number Diff line change @@ -113,55 +113,62 @@ auto parse_options(int argc, char **argv)
113
113
114
114
int opt = 0 ;
115
115
while ((opt = getopt (argc, argv, " h:p:a:n:c:k:v:r:t:bs:" )) != -1 ) {
116
- switch (opt) {
117
- case ' h' :
118
- host = optarg;
119
- break ;
120
-
121
- case ' p' :
122
- port = std::stoi (optarg);
123
- break ;
124
-
125
- case ' a' :
126
- auth = optarg;
127
- break ;
128
-
129
- case ' n' :
130
- cluster_node = optarg;
131
- break ;
132
-
133
- case ' c' :
134
- cluster_port = std::stoi (optarg);
135
- break ;
136
-
137
- case ' b' :
138
- benchmark = true ;
139
- break ;
140
-
141
- case ' k' :
142
- tmp_benchmark_opts.key_len = std::stoi (optarg);
143
- break ;
144
-
145
- case ' v' :
146
- tmp_benchmark_opts.val_len = std::stoi (optarg);
147
- break ;
148
-
149
- case ' r' :
150
- tmp_benchmark_opts.total_request_num = std::stoi (optarg);
151
- break ;
152
-
153
- case ' t' :
154
- tmp_benchmark_opts.thread_num = std::stoi (optarg);
155
- break ;
156
-
157
- case ' s' :
158
- tmp_benchmark_opts.pool_size = std::stoi (optarg);
159
- break ;
160
-
161
- default :
116
+ try {
117
+ switch (opt) {
118
+ case ' h' :
119
+ host = optarg;
120
+ break ;
121
+
122
+ case ' p' :
123
+ port = std::stoi (optarg);
124
+ break ;
125
+
126
+ case ' a' :
127
+ auth = optarg;
128
+ break ;
129
+
130
+ case ' n' :
131
+ cluster_node = optarg;
132
+ break ;
133
+
134
+ case ' c' :
135
+ cluster_port = std::stoi (optarg);
136
+ break ;
137
+
138
+ case ' b' :
139
+ benchmark = true ;
140
+ break ;
141
+
142
+ case ' k' :
143
+ tmp_benchmark_opts.key_len = std::stoi (optarg);
144
+ break ;
145
+
146
+ case ' v' :
147
+ tmp_benchmark_opts.val_len = std::stoi (optarg);
148
+ break ;
149
+
150
+ case ' r' :
151
+ tmp_benchmark_opts.total_request_num = std::stoi (optarg);
152
+ break ;
153
+
154
+ case ' t' :
155
+ tmp_benchmark_opts.thread_num = std::stoi (optarg);
156
+ break ;
157
+
158
+ case ' s' :
159
+ tmp_benchmark_opts.pool_size = std::stoi (optarg);
160
+ break ;
161
+
162
+ default :
163
+ throw sw::redis::Error (" Unknow command line option" );
164
+ break ;
165
+ }
166
+ } catch (const sw::redis::Error &e) {
167
+ print_help ();
168
+ throw ;
169
+ } catch (const std::exception &e) {
162
170
print_help ();
163
- throw sw::redis::Error (" Failed to parse connection options" );
164
- break ;
171
+ throw sw::redis::Error (" Invalid command line option" );
165
172
}
166
173
}
167
174
You can’t perform that action at this time.
0 commit comments