message: add -i option to pcm-iio.cpp
diff: @@ -1122,8 +1122,9 @@ void print_usage(const string& progname)
  << " to a file, in case filename is provided\n";
  cerr << " -csv-delimiter=<value> | /csv-delimiter=<value> => set custom csv delimiter\n";
  cerr << " -human-readable | /human-readable => use human readable format for output (for csv only)\n";
  + cerr << " -i[=number] | /i[=number] => allow to determine number of iterations\n";
  cerr << " Examples:\n";
  - cerr << " " << progname << " 1.0 => print counters every second\n";
  + cerr << " " << progname << " 1.0 -i=10 => print counters every second 10 times and exit\n";
  cerr << " " << progname << " 0.5 -csv=test.log => twice a second save counter values to test.log in CSV format\n";
  cerr << " " << progname << " -csv -human-readable => every 3 second print counters in human-readable CSV format\n";
  cerr << "\n";
  @@ -1145,6 +1146,7 @@ int main(int argc, char * argv[])
  std::string csv_delimiter = ",";
  std::string output_file;
  double delay = PCM_DELAY_DEFAULT;
  + MainLoop mainLoop;
  PCM * m = PCM::getInstance();
  while (argc > 1) {
  @@ -1168,6 +1170,9 @@ int main(int argc, char * argv[])
  else if (check_argument_equals(*argv, {"-human-readable", "/human-readable"})) {
  human_readable = true;
  }
  + else if (mainLoop.parseArg(*argv)) {
  + continue;
  + }
  else {
  // any other options positional that is a floating point number is treated as <delay>,
  // while the other options are ignored with a warning issues to stderr
  @@ -1252,11 +1257,15 @@ int main(int argc, char * argv[])
  output = &file_stream;
  }
  - while (1) {
  + mainLoop([&]()
  + {
  collect_data(m, delay, iios, counters);
  vector<string> display_buffer = csv ?
  build_csv(iios, counters, human_readable, csv_delimiter) :
  build_display(iios, counters, pciDB);
  display(display_buffer, *output);
  - };
  + return true;
  + });
  +
  + exit(EXIT_SUCCESS);
  }
  