| 3 | #include <iostream> |
| 4 | |
| 5 | int main(int argc, char **argv) { |
| 6 | |
| 7 | /// [Intro] |
| 8 | CLI::App app{"Geet, a command line git lookalike that does nothing"}; |
| 9 | app.require_subcommand(1); |
| 10 | /// [Intro] |
| 11 | |
| 12 | /// [Add] |
| 13 | auto add = app.add_subcommand("add", "Add file(s)"); |
| 14 | |
| 15 | bool add_update; |
| 16 | add->add_flag("-u,--update", add_update, "Add updated files only"); |
| 17 | |
| 18 | std::vector<std::string> add_files; |
| 19 | add->add_option("files", add_files, "Files to add"); |
| 20 | |
| 21 | add->callback([&]() { |
| 22 | std::cout << "Adding:"; |
| 23 | if(add_files.empty()) { |
| 24 | if(add_update) |
| 25 | std::cout << " all updated files"; |
| 26 | else |
| 27 | std::cout << " all files"; |
| 28 | } else { |
| 29 | for(auto file : add_files) |
| 30 | std::cout << " " << file; |
| 31 | } |
| 32 | }); |
| 33 | /// [Add] |
| 34 | |
| 35 | /// [Commit] |
| 36 | auto commit = app.add_subcommand("commit", "Commit files"); |
| 37 | |
| 38 | std::string commit_message; |
| 39 | commit->add_option("-m,--message", commit_message, "A message")->required(); |
| 40 | |
| 41 | commit->callback([&]() { std::cout << "Commit message: " << commit_message; }); |
| 42 | /// [Commit] |
| 43 | |
| 44 | /// [Parse] |
| 45 | CLI11_PARSE(app, argc, argv); |
| 46 | |
| 47 | std::cout << "\nThanks for using geet!\n" << std::endl; |
| 48 | return 0; |
| 49 | /// [Parse] |
| 50 | } |
nothing calls this directly
no test coverage detected