You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

main.cpp 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include <QCoreApplication>
  2. #include <QStringList>
  3. #include "mainclass.h"
  4. void printUsage()
  5. {
  6. qDebug()<<"Usage: netsouldc [options] (events|ns|users)";
  7. qDebug()<<"\t-h, --help \t\t print this help.";
  8. qDebug()<<"\t-k, --keep \t\t keep session active if queries are provided in arguments. Exit by default.";
  9. qDebug()<<"\t-r, --responseOnly \t only print the responses, but not the info, ok and error.";
  10. qDebug()<<"\t-p, --pid file \t\t indicate the file path to write de pid.";
  11. qDebug()<<"\t-c, --color \t\t disable the colors in the info, ok and error.";
  12. }
  13. int main(int argc, char *argv[])
  14. {
  15. QCoreApplication a(argc, argv);
  16. MainClass m;
  17. m.setCloseOnNextQuery(qApp->argc() >= 2);
  18. QStringList cmds;
  19. for(int i = 1; i < qApp->argc(); ++i)
  20. {
  21. QString c = qApp->arguments().at(i);
  22. if(c == "-h" || c == "--help")
  23. {
  24. printUsage();
  25. return 0;
  26. }
  27. else if(c == "-k" || c == "--keep")
  28. m.setCloseOnNextQuery(false);
  29. else if(c == "-r" || c == "--responseOnly")
  30. m.setShowOnlyResponse(true);
  31. else if(c == "-c" || c == "--color")
  32. m.setColored(false);
  33. else
  34. cmds.append(c);
  35. }
  36. m.addCommands(cmds);
  37. m.connectToDaemon();
  38. return a.exec();
  39. }