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.

38 lines
919 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 <string>
  12. #include <clipp.h>
  13. int main(int argc, char* argv[])
  14. {
  15. using namespace clipp;
  16. using std::cout;
  17. std::string fname;
  18. std::string enc = "utf8";
  19. auto cli = (
  20. command("new"),
  21. value("filename", fname),
  22. (option("-e", "--encoding") & value("enc", enc)).doc("'utf8' or 'cp1252', default is " + enc)
  23. );
  24. if(parse(argc, argv, cli)) {
  25. cout << "making file " << fname << " with encoding " << enc << '\n';
  26. }
  27. else {
  28. cout << "Usage:\n" << usage_lines(cli,argv[0]) << '\n';
  29. }
  30. }