From 9db62cb338aeaed1fec5806f6b5d9781f5e19e4c Mon Sep 17 00:00:00 2001 From: Jarryd Beck Date: Thu, 18 May 2017 08:03:19 +1000 Subject: [PATCH] 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. --- include/cxxopts.hpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/include/cxxopts.hpp b/include/cxxopts.hpp index 3036504..5afc307 100644 --- a/include/cxxopts.hpp +++ b/include/cxxopts.hpp @@ -482,14 +482,7 @@ namespace cxxopts void parse(const std::string& text) const { - if (m_implicit && text.empty()) - { - parse_value(m_implicit_value, *m_store); - } - else - { - parse_value(text, *m_store); - } + parse_value(text, *m_store); } bool @@ -1028,7 +1021,7 @@ Options::checked_parse_arg { if (value->value().has_implicit()) { - parse_option(value, name, ""); + parse_option(value, name, value->value().get_implicit_value()); } else { @@ -1039,7 +1032,7 @@ Options::checked_parse_arg { if (argv[current + 1][0] == '-' && value->value().has_implicit()) { - parse_option(value, name, ""); + parse_option(value, name, value->value().get_implicit_value()); } else { @@ -1181,7 +1174,7 @@ Options::parse(int& argc, char**& argv) } else if (value->value().has_implicit()) { - parse_option(value, name, ""); + parse_option(value, name, value->value().get_implicit_value()); } else {