fix default
This commit is contained in:
parent
65beaeb2e9
commit
b1f0cb806c
@ -9,6 +9,8 @@ options. The project adheres to semantic versioning.
|
||||
|
||||
* `Options::parse` returns a ParseResult rather than storing the parse
|
||||
result internally.
|
||||
* Options with default values now get counted as appearing once if they
|
||||
were not specified by the user.
|
||||
|
||||
### Added
|
||||
|
||||
|
||||
@ -887,12 +887,6 @@ namespace cxxopts
|
||||
m_value->parse();
|
||||
}
|
||||
|
||||
int
|
||||
count() const
|
||||
{
|
||||
return m_count;
|
||||
}
|
||||
|
||||
const Value& value() const {
|
||||
return *m_value;
|
||||
}
|
||||
@ -961,6 +955,7 @@ namespace cxxopts
|
||||
{
|
||||
ensure_value(details);
|
||||
m_value->parse();
|
||||
m_count++;
|
||||
}
|
||||
|
||||
size_t
|
||||
@ -1645,7 +1640,9 @@ ParseResult::parse(int& argc, char**& argv)
|
||||
auto& detail = opt.second;
|
||||
auto& value = detail->value();
|
||||
|
||||
if(!detail->count() && value.has_default()){
|
||||
auto& store = m_results[detail];
|
||||
|
||||
if(!store.count() && value.has_default()){
|
||||
parse_default(detail);
|
||||
}
|
||||
}
|
||||
|
||||
@ -238,7 +238,7 @@ TEST_CASE("Default values", "[default]")
|
||||
}
|
||||
|
||||
SECTION("When values provided") {
|
||||
Argv av({"implicit", "default", "5"});
|
||||
Argv av({"implicit", "--default", "5"});
|
||||
|
||||
char** argv = av.argv();
|
||||
auto argc = av.argc();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user