@@ -209,9 +209,57 @@ INSTANTIATE_TEST_SUITE_P(TestAccuracy,
209209 return std::to_string (info.index ) + " _" + info.param .type ; // So test name will be "case1"
210210 });
211211
212+ class InputParser {
213+ public:
214+ InputParser (int & argc, char ** argv) {
215+ for (int i = 1 ; i < argc; ++i)
216+ this ->tokens .push_back (std::string (argv[i]));
217+ }
218+
219+ const std::string& getCmdOption (const std::string& option) const {
220+ std::vector<std::string>::const_iterator itr;
221+ itr = std::find (this ->tokens .begin (), this ->tokens .end (), option);
222+ if (itr != this ->tokens .end () && ++itr != this ->tokens .end ()) {
223+ return *itr;
224+ }
225+ static const std::string empty_string (" " );
226+ return empty_string;
227+ }
228+
229+ bool cmdOptionExists (const std::string& option) const {
230+ return std::find (this ->tokens .begin (), this ->tokens .end (), option) != this ->tokens .end ();
231+ }
232+
233+ private:
234+ std::vector<std::string> tokens;
235+ };
236+
237+ void print_help (const char * program_name) {
238+ std::cout << " Usage: " << program_name << " -p <path_to_public_scope.json> -d <path_to_data>" << std::endl;
239+ }
240+
241+
212242int main (int argc, char ** argv) {
213- PUBLIC_SCOPE_PATH = argv[1 ];
214- DATA_DIR = argv[2 ];
243+ InputParser input (argc, argv);
244+
245+ if (input.cmdOptionExists (" -h" )) {
246+ print_help (argv[0 ]);
247+ return 1 ;
248+ }
249+ const std::string& public_scope = input.getCmdOption (" -p" );
250+ if (!public_scope.empty ()) {
251+ PUBLIC_SCOPE_PATH = public_scope;
252+ } else {
253+ print_help (argv[0 ]);
254+ return 1 ;
255+ }
256+ const std::string& data_dir = input.getCmdOption (" -d" );
257+ if (!data_dir.empty ()) {
258+ DATA_DIR = data_dir;
259+ } else {
260+ print_help (argv[0 ]);
261+ return 1 ;
262+ }
215263
216264 testing::InitGoogleTest (&argc, argv);
217265
0 commit comments