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.

45 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 <clipp.h>
  13. int main(int argc, char* argv[])
  14. {
  15. using namespace clipp;
  16. using std::cout;
  17. std::string ifile, ofile;
  18. bool split = false;
  19. auto cli = (
  20. value("infile", ifile) % "input filename",
  21. value("outfile", ofile) % "output filename",
  22. option("-s", "--split").set(split) % "split files" );
  23. if(parse(argc, argv, cli)) {
  24. cout << "input file: " << ifile << '\n'
  25. << "output file: " << ofile << '\n'
  26. << "Files will " << (split ? "" : "not") << " be split.";
  27. }
  28. else {
  29. cout << make_man_page(cli, argv[0]) << '\n';
  30. }
  31. // alternative style:
  32. // auto cli = (
  33. // value("infile") % "input filename" >> ifile,
  34. // value("outfile") % "output filename" >> ofile,
  35. // option("-s", "--split") % "split files" >> split );
  36. }