src/cli.cpp
/**
 * Parse the command line arguments, updating a config as appropriate.
 */
Parse the command line arguments, updating a config as appropriate.
Parse the command line arguments updating a config as appropriate .
void Cli::parse(int argc, char ** argv, Config * cfg)
{
  int c;
  char * progname = argv[0];
  while (1) {
    int option_index = 0;
    c = getopt_long(argc, argv, argp, longopts, &option_index);
    if (c == -1)
      break;
    switch (c) {
      case 'd':
        cfg->setDiscardThreshold(::atof(optarg));
        break;
      case 'i':
        cfg->setInterface(optarg);
        break;
      case 'l':
        cfg->setLogfile(optarg);
        break;
      case 'p':
        cfg->setPort(::atoi(optarg));
        break;
      case 'r':
        cfg->setRefreshInterval(::atoi(optarg));
        break;
      case 'R':
        cfg->setReportType(optarg);
        break;
      case 'h':
        cout << Cli::help(progname);
        exit(EXIT_SUCCESS);
      case 'v':
        cfg->increaseVerbosity();
        break;
      case 'V':
        cout << "Package: " << PACKAGE_STRING << endl;
        cout << "Author : " << PACKAGE_BUGREPORT << endl;
        cout << "License: Apache 2.0" << endl;
        exit(EXIT_SUCCESS);
      case '?':
        cout << "Unknown flag specified" << endl;
        cout << Cli::help(progname);
        exit(EXIT_FAILURE);
      default:
        cout << "Unknown flag specified" << endl;
        cout << Cli::help(progname);
        exit(EXIT_FAILURE);
    }
  }
}
void Cli :: parse ( int argc , char * * argv , Config * cfg ) { int c ; char * progname = argv [ 0 ] ; while ( 1 ) { int option_index = 0 ; c = getopt_long ( argc , argv , argp , longopts , & option_index ) ; if ( c == -1 ) break ; switch ( c ) { case ' ' : cfg -> setDiscardThreshold ( :: atof ( optarg ) ) ; break ; case ' ' : cfg -> setInterface ( optarg ) ; break ; case ' ' : cfg -> setLogfile ( optarg ) ; break ; case ' ' : cfg -> setPort ( :: atoi ( optarg ) ) ; break ; case ' ' : cfg -> setRefreshInterval ( :: atoi ( optarg ) ) ; break ; case ' ' : cfg -> setReportType ( optarg ) ; break ; case ' ' : cout << Cli :: help ( progname ) ; exit ( EXIT_SUCCESS ) ; case ' ' : cfg -> increaseVerbosity ( ) ; break ; case ' ' : cout << " " << PACKAGE_STRING << endl ; cout << " " << PACKAGE_BUGREPORT << endl ; cout << " " << endl ; exit ( EXIT_SUCCESS ) ; case ' ' : cout << " " << endl ; cout << Cli :: help ( progname ) ; exit ( EXIT_FAILURE ) ; default : cout << " " << endl ; cout << Cli :: help ( progname ) ; exit ( EXIT_FAILURE ) ; } } }
Parse the command line arguments, updating a config as appropriate.
Parse the command line arguments updating a config as appropriate .