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.

39 lines
846 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 <clipp.h>
  13. int main(int argc, char* argv[])
  14. {
  15. using namespace clipp;
  16. using std::cout;
  17. int as = 0;
  18. int bs = 0;
  19. auto cli = joinable(
  20. repeatable(
  21. option("a")([&]{++as;}) |
  22. option("b")([&]{++bs;})
  23. )
  24. );
  25. if(parse(argc, argv, cli)) {
  26. cout << "as: " << as << '\n';
  27. cout << "bs: " << bs << '\n';
  28. } else {
  29. cout << "Usage:\n" << usage_lines(cli, argv[0]) << '\n';
  30. }
  31. }