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.

41 lines
965 B

2 years ago
  1. /*****************************************************************************
  2. *
  3. * demo program - part of CLIPP (command line interfaces for modern C++)
  4. *
  5. * released under MIT license
  6. *
  7. * (c) 2017-2018 André Müller; foss@andremueller-online.de
  8. *
  9. *****************************************************************************/
  10. #include <iostream>
  11. #include <vector>
  12. #include <cmath>
  13. #include <clipp.h>
  14. int main(int argc, char* argv[])
  15. {
  16. using namespace clipp;
  17. using std::cout;
  18. std::string progcall;
  19. bool x = false;
  20. bool y = false;
  21. auto cli = (
  22. value("", progcall),
  23. option("-x").set(x),
  24. option("-y").set(y)
  25. );
  26. //parse all args including argv[0]
  27. if(parse(argv, argv+argc, cli)) {
  28. cout << "program call: " << progcall << '\n';
  29. if(x) cout << "x\n";
  30. if(y) cout << "y\n";
  31. } else {
  32. cout << "Usage:\n" << usage_lines(cli,argv[0]) << '\n';
  33. }
  34. }