| 9 | #include <string> |
| 10 | |
| 11 | int main(int argc, char **argv) { |
| 12 | |
| 13 | CLI::App app("data output specification"); |
| 14 | app.set_help_all_flag("--help-all", "Expand all help"); |
| 15 | |
| 16 | auto *format = app.add_option_group("output_format", "formatting type for output"); |
| 17 | auto *target = app.add_option_group("output target", "target location for the output"); |
| 18 | bool csv{false}; |
| 19 | bool human{false}; |
| 20 | bool binary{false}; |
| 21 | format->add_flag("--csv", csv, "specify the output in csv format"); |
| 22 | format->add_flag("--human", human, "specify the output in human readable text format"); |
| 23 | format->add_flag("--binary", binary, "specify the output in binary format"); |
| 24 | // require one of the options to be selected |
| 25 | format->require_option(1); |
| 26 | std::string fileLoc; |
| 27 | std::string networkAddress; |
| 28 | target->add_option("-o,--file", fileLoc, "specify the file location of the output"); |
| 29 | target->add_option("--address", networkAddress, "specify a network address to send the file"); |
| 30 | |
| 31 | // require at most one of the target options |
| 32 | target->require_option(0, 1); |
| 33 | CLI11_PARSE(app, argc, argv); |
| 34 | |
| 35 | std::string format_type = (csv) ? std::string("CSV") : ((human) ? "human readable" : "binary"); |
| 36 | std::cout << "Selected " << format_type << " format\n"; |
| 37 | if(!fileLoc.empty()) { |
| 38 | std::cout << " sent to file " << fileLoc << '\n'; |
| 39 | } else if(!networkAddress.empty()) { |
| 40 | std::cout << " sent over network to " << networkAddress << '\n'; |
| 41 | } else { |
| 42 | std::cout << " sent to std::cout\n"; |
| 43 | } |
| 44 | |
| 45 | return 0; |
| 46 | } |
nothing calls this directly
no test coverage detected