Commit 9db62cb338aeaed1fec5806f6b5d9781f5e19e4c

Authored by Jarryd Beck
1 parent cca5472d

Fix broken implicit_value when given empty

Fixes #46. When an option had an implicit value, and an empty string was
passed on the command line, the implicit value would be used instead.
Showing 1 changed file with 4 additions and 11 deletions
include/cxxopts.hpp
... ... @@ -482,14 +482,7 @@ namespace cxxopts
482 482 void
483 483 parse(const std::string& text) const
484 484 {
485   - if (m_implicit && text.empty())
486   - {
487   - parse_value(m_implicit_value, *m_store);
488   - }
489   - else
490   - {
491   - parse_value(text, *m_store);
492   - }
  485 + parse_value(text, *m_store);
493 486 }
494 487  
495 488 bool
... ... @@ -1028,7 +1021,7 @@ Options::checked_parse_arg
1028 1021 {
1029 1022 if (value->value().has_implicit())
1030 1023 {
1031   - parse_option(value, name, "");
  1024 + parse_option(value, name, value->value().get_implicit_value());
1032 1025 }
1033 1026 else
1034 1027 {
... ... @@ -1039,7 +1032,7 @@ Options::checked_parse_arg
1039 1032 {
1040 1033 if (argv[current + 1][0] == '-' && value->value().has_implicit())
1041 1034 {
1042   - parse_option(value, name, "");
  1035 + parse_option(value, name, value->value().get_implicit_value());
1043 1036 }
1044 1037 else
1045 1038 {
... ... @@ -1181,7 +1174,7 @@ Options::parse(int& argc, char**& argv)
1181 1174 }
1182 1175 else if (value->value().has_implicit())
1183 1176 {
1184   - parse_option(value, name, "");
  1177 + parse_option(value, name, value->value().get_implicit_value());
1185 1178 }
1186 1179 else
1187 1180 {
... ...