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.

40 lines
1.1 KiB

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 <string>
  12. #include <clipp.h>
  13. int main(int argc, char* argv[])
  14. {
  15. using namespace clipp;
  16. using std::cout;
  17. int n = 0;
  18. bool domerge = false;
  19. long m = 5;
  20. auto print_ratio = [](const char* r) { cout << "using ratio of " << r << '\n'; };
  21. auto cli = (
  22. (option("-n", "--count") & value("count", n)) % "number of iterations",
  23. (option("-r", "--ratio") & value("ratio", print_ratio)) % "compression ratio",
  24. (option("-m") & opt_value("lines=5", m).set(domerge)) % "merge lines (default: 5)"
  25. );
  26. if(parse(argc, argv, cli)) {
  27. cout << "performing " << n << " iterations\n";
  28. if(domerge) cout << "merge " << m << " lines\n";
  29. }
  30. else {
  31. cout << make_man_page(cli, argv[0]) << '\n';
  32. }
  33. }