MCPcopy Create free account
hub / github.com/EQEmu/EQEmu / ValidateCmdInput

Function ValidateCmdInput

common/cli/eqemu_command_handler.cpp:62–106  ·  view source on GitHub ↗

* @param arguments * @param options * @param cmd * @param argc * @param argv */

Source from the content-addressed store, hash-verified

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

Calls 2

emptyMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected