std::vector<const char*> get_cmd_args(char** begin, char** end)
{
- for (char** itr = end-1; itr != begin-1; --itr)
+ std::vector<const char*> list;
+ for (char** itr = begin+1; itr != end; itr++)
{
- if (itr != end && strncmp(*itr, "--", 2) == 0)
- {
- itr++;
- int len = end - itr;
- return std::vector<const char*>(len, *itr);
- }
+ if (strncmp(*itr, "--", 2) != 0)
+ list.push_back(*itr);
}
- return std::vector<const char*>(end-begin-1, *(begin+1));
+ return list;
}
bool cmd_option_exists(char** begin, char** end, const std::string& option)
help(argv[0]);
return 0;
}
-
- if (cmd_option_exists(argv, argv+argc, "--system"))
+ else if (cmd_option_exists(argv, argv+argc, "--system"))
{
create_ni_platform();
return 0;
}
-
- if (cmd_option_exists(argv, argv+argc, "--dll"))
+ else if (cmd_option_exists(argv, argv+argc, "--dll"))
{
dll_mode = true;
}
-
- if (cmd_option_exists(argv, argv+argc, "--pkg"))
+ else if (cmd_option_exists(argv, argv+argc, "--pkg"))
{
pkg_mode = true;
}
+ else {
+ help(argv[0]);
+ return 1;
+ }
std::vector<const char*> args = get_cmd_args(argv, argv+argc);