Commit 3ce8cbd1aebaba44873bd9aa4a7a81661dd36715

Authored by Jarryd Beck
1 parent b2e7efe7

add support for --

Showing 1 changed file with 20 additions and 1 deletions
src/cxxopts.hpp
1 /* 1 /*
2 2
3 -Copyright (c) 2014, 2015 Jarryd Beck 3 +Copyright (c) 2014, 2015, 2016 Jarryd Beck
4 4
5 Permission is hereby granted, free of charge, to any person obtaining a copy 5 Permission is hereby granted, free of charge, to any person obtaining a copy
6 of this software and associated documentation files (the "Software"), to deal 6 of this software and associated documentation files (the "Software"), to deal
@@ -1067,8 +1067,17 @@ Options::parse(int& argc, char**& argv) @@ -1067,8 +1067,17 @@ Options::parse(int& argc, char**& argv)
1067 1067
1068 int nextKeep = 1; 1068 int nextKeep = 1;
1069 1069
  1070 + bool consume_remaining = false;
  1071 +
1070 while (current != argc) 1072 while (current != argc)
1071 { 1073 {
  1074 + if (strcmp(argv[current], "--") == 0)
  1075 + {
  1076 + consume_remaining = true;
  1077 + ++current;
  1078 + break;
  1079 + }
  1080 +
1072 std::match_results<const char*> result; 1081 std::match_results<const char*> result;
1073 std::regex_match(argv[current], result, option_matcher); 1082 std::regex_match(argv[current], result, option_matcher);
1074 1083
@@ -1187,7 +1196,17 @@ Options::parse(int&amp; argc, char**&amp; argv) @@ -1187,7 +1196,17 @@ Options::parse(int&amp; argc, char**&amp; argv)
1187 } 1196 }
1188 } 1197 }
1189 1198
  1199 + if (consume_remaining)
  1200 + {
  1201 + while (current < argc)
  1202 + {
  1203 + consume_positional(argv[current]);
  1204 + ++current;
  1205 + }
  1206 + }
  1207 +
1190 argc = nextKeep; 1208 argc = nextKeep;
  1209 +
1191 } 1210 }
1192 1211
1193 void 1212 void