* @param arguments * @param options * @param cmd * @param argc * @param argv */
| 60 | * @param argv |
| 61 | */ |
| 62 | void ValidateCmdInput( |
| 63 | std::vector<std::string> &arguments, |
| 64 | std::vector<std::string> &options, |
| 65 | argh::parser &cmd, |
| 66 | int argc, |
| 67 | char **argv |
| 68 | ) |
| 69 | { |
| 70 | bool arguments_filled = true; |
| 71 | |
| 72 | int index = 2; |
| 73 | for (auto &arg: arguments) { |
| 74 | if (cmd(arg).str().empty() && cmd(index).str().empty()) { |
| 75 | arguments_filled = false; |
| 76 | } |
| 77 | index++; |
| 78 | } |
| 79 | |
| 80 | if (!arguments_filled || (argc == 2 && !cmd[{"-h", "--help"}]) || (argc == 3 && cmd[{"-h", "--help"}])) { |
| 81 | std::string arguments_string; |
| 82 | for (auto &arg: arguments) { |
| 83 | arguments_string += " " + arg; |
| 84 | } |
| 85 | |
| 86 | std::string options_string; |
| 87 | for (auto &opt: options) { |
| 88 | options_string += " " + opt + "\n"; |
| 89 | } |
| 90 | |
| 91 | std::stringstream command_string; |
| 92 | |
| 93 | command_string << |
| 94 | termcolor::colorize << |
| 95 | termcolor::yellow << |
| 96 | "\nCommand" << |
| 97 | termcolor::reset << "\n\n" << |
| 98 | termcolor::green << argv[1] << arguments_string << termcolor::reset << "\n" << |
| 99 | termcolor::yellow << (!options_string.empty() ? "\nOptions\n\n" : "") << |
| 100 | termcolor::reset << termcolor::cyan << options_string << termcolor::reset; |
| 101 | |
| 102 | std::cout << command_string.str() << std::endl; |
| 103 | |
| 104 | exit(0); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * @param in_function_map |
no test coverage detected