@@ -102,6 +102,16 @@ bool parseArgs(int argc, char *argv[], ConsumerOptions &options) {
102102 }
103103 return {};
104104 };
105+ auto matchingOutputFlag = [](const std::string &arg) -> const char * {
106+ static constexpr const char *kOutputFlags [] = {" --output-dir" , " --output" ,
107+ " --ouput" };
108+ for (const char *flag : kOutputFlags ) {
109+ if (arg.rfind (flag, 0 ) == 0 ) {
110+ return flag;
111+ }
112+ }
113+ return nullptr ;
114+ };
105115
106116 for (int index = 1 ; index < argc; ++index) {
107117 const std::string arg = argv[index];
@@ -113,12 +123,9 @@ bool parseArgs(int argc, char *argv[], ConsumerOptions &options) {
113123 options.url = readFlagValue (" --url" , index);
114124 } else if (arg.rfind (" --token" , 0 ) == 0 ) {
115125 options.token = readFlagValue (" --token" , index);
116- } else if (arg.rfind (" --output-dir" , 0 ) == 0 ) {
117- options.output_dir = readFlagValue (" --output-dir" , index);
118- } else if (arg.rfind (" --output" , 0 ) == 0 ) {
119- options.output_dir = readFlagValue (" --output" , index);
120- } else if (arg.rfind (" --ouput" , 0 ) == 0 ) {
121- options.output_dir = readFlagValue (" --ouput" , index);
126+ } else if (const char *output_flag = matchingOutputFlag (arg);
127+ output_flag != nullptr ) {
128+ options.output_dir = readFlagValue (output_flag, index);
122129 } else if (arg.rfind (" --track-name" , 0 ) == 0 ) {
123130 options.track_name = readFlagValue (" --track-name" , index);
124131 } else if (arg.rfind (" --quiet-period-ms" , 0 ) == 0 ) {
@@ -423,7 +430,8 @@ class ThroughputConsumer {
423430 }
424431
425432 void appendSummaryRow (const json &summary) const {
426- std::ofstream out (summary_csv_path_, std::ios::app);
433+ std::ofstream out;
434+ out.open (summary_csv_path_, std::ios::app);
427435 if (!out) {
428436 throw std::runtime_error (" Failed to open summary CSV for append" );
429437 }
@@ -455,7 +463,8 @@ class ThroughputConsumer {
455463 return lhs.arrival_time_us < rhs.arrival_time_us ;
456464 });
457465
458- std::ofstream out (message_csv_path_, std::ios::app);
466+ std::ofstream out;
467+ out.open (message_csv_path_, std::ios::app);
459468 if (!out) {
460469 throw std::runtime_error (" Failed to open message CSV for append" );
461470 }
0 commit comments