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.

67 lines
2.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()
  14. {
  15. using namespace clipp;
  16. using std::cout;
  17. auto cli = (
  18. command("help") |
  19. ( command("build"),
  20. "build commands" %
  21. ( command("new") % "make new database"
  22. | command("add") % "append to existing database"
  23. ),
  24. value("file")
  25. ) |
  26. ( command("query"),
  27. "query settings" %
  28. ( required("-i", "--input") & value("infile") % "input file",
  29. option("-p", "--pretty-print") % "human friendly output")
  30. ) |
  31. ( command("info"),
  32. "database info modes" % (
  33. command("space") % "detailed memory occupation analysis" |
  34. (
  35. command("statistics"),
  36. "statistics analysis" % (
  37. command("words") % "word frequency table" |
  38. command("chars") % "character frequency table"
  39. )
  40. )
  41. )
  42. ) |
  43. "remove mode" % (
  44. command("remove"),
  45. "modify" % ( command("any") | command("all") ),
  46. value("regex") % "regular expression filter"
  47. ) |
  48. ( command("modify"),
  49. "modification opererations" % (
  50. option("-c", "--compress") % "compress database in-memory",
  51. option("-u", "--unique") % "keep only unique entries",
  52. option("-m", "--memlimit") % "max. size in RAM" & value("size")
  53. )
  54. )
  55. );
  56. auto fmt = doc_formatting{} .first_column(4) .doc_column(28);
  57. cout << make_man_page(cli, "worddb", fmt)
  58. .prepend_section("DESCRIPTION", " Builds a database of words from text files.")
  59. .append_section("LICENSE", " GPL3") << '\n';
  60. }