29 std::vector<std::pair<std::string, std::string>> &m_command_vector) {
34 const int &argc,
const std::map<std::string, struct Argument> &command_map,
35 std::vector<std::pair<std::string, int>> &arg_position) {
36 for (
auto ct = command_map.begin(); ct != command_map.end(); ct++) {
37 if (ct->second.is_mandatory ==
true) {
38 if (ct->second.position ==
"last") {
39 arg_position.push_back({ct->first, argc - 1});
41 arg_position.push_back(
42 {ct->first, std::stoi(ct->second.position)});
49 return arg.find(
"-h") != std::string::npos ||
50 arg.find(
"--help") != std::string::npos;
54 return arg.find(
"=") != std::string::npos;
58 return (arg.substr(0, 2) ==
"--") || (arg.substr(0, 1) ==
"-");
64 std::vector<std::pair<std::string, std::string>> &m_command_vector) {
70 const std::string &arg,
int &arg_number,
const int &euqal_pos,
71 std::vector<std::pair<std::string, std::string>> &m_command_vector) {
72 addCommand(arg.substr(0, euqal_pos), arg.substr(euqal_pos + 1),
79 std::vector<std::pair<std::string, std::string>> &m_command_vector) {
86 std::vector<std::pair<std::string, std::string>> &m_command_vector,
87 const std::map<std::string, struct Argument> &command_map) {
88 bool arg_found =
false;
89 for (
const auto &entry : command_map) {
90 const Argument &argument = entry.second;
110 std::vector<std::pair<std::string, std::string>> &m_command_vector,
111 const std::map<std::string, struct Argument> &command_map) {
112 auto command = command_map.find(arg);
113 if (
command != command_map.end()) {
114 if (
command->second.has_value) {
127 int argc,
char *argv[],
128 std::map<std::string, struct Argument> command_map) {
132 std::vector<std::pair<std::string, int>> arg_position;
136 for (
int i = 1;
i < argc;
i++) {
137 bool mandatory =
false;
139 for (
int j = 0; j < arg_position.size(); j++) {
140 if (arg_number == arg_position[j].second && !
isHelpArg(argv[
i])) {
144 }
else if (arg_number != argc - 1) {
184 std::map<std::string, struct Argument> &command_map,
188 bool is_command =
false;
189 for (
auto ct = command_map.begin(); ct != command_map.end(); ct++) {
218 std::map<std::string, struct Argument> &command_map,
223 for (
auto ct = command_map.begin(); ct != command_map.end(); ct++) {
227 ct->second.value ==
"") {
228 arg_error = ct->first;
231 ct->second.value !=
"") {
246 std::map<std::string, struct Argument> &command_map,
249 for (
auto ct = command_map.begin(); ct != command_map.end(); ct++) {
250 if (ct->second.is_mandatory ==
true && ct->second.value ==
"") {
251 arg_error = ct->first;
259 std::map<std::string, struct Argument> &command_map,
262 for (
auto ct = command_map.begin(); ct != command_map.end(); ct++) {
263 if (ct->second.is_mandatory ==
true) {
265 if (ct->second.position !=
"last") {
266 index = std::stoi(ct->second.position) - 1;
272 arg_error = ct->first;