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.

48 lines
1.2 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 <vector>
  13. #include <clipp.h>
  14. int main(int argc, char* argv[])
  15. {
  16. using namespace clipp;
  17. using std::cout;
  18. std::vector<std::string> files;
  19. std::vector<int> lines;
  20. bool zip = false;
  21. auto cli = (
  22. "input files" %
  23. values("file", files),
  24. "compress results" %
  25. option("-c", "--compress").set(zip),
  26. "lines to be ignored" %
  27. repeatable( option("-i", "--ignore") & integers("line", lines) )
  28. );
  29. if(parse(argc, argv, cli)) {
  30. cout << "files:\n";
  31. for(const auto& f : files) cout << " " << f << '\n';
  32. cout << "lines to be ignored: ";
  33. for(const auto& l : lines) cout << l << ' ';
  34. cout << "\nusing" << (zip ? "" : " no") << " compression\n";
  35. }
  36. else {
  37. cout << make_man_page(cli, argv[0]) << '\n';
  38. }
  39. }