Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes in latest release #1005

Merged
merged 3 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions include/CLI/impl/App_inl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,11 +1136,9 @@ CLI11_INLINE void App::_process_env() {
}

for(App_p &sub : subcommands_) {
if(sub->get_name().empty() || !sub->parse_complete_callback_) {
if(sub->count_all() > 0) {
// only process environment variables if the callback has actually been triggered already
sub->_process_env();
}
if(sub->get_name().empty() || (sub->count_all() > 0 && !sub->parse_complete_callback_)) {
// only process environment variables if the callback has actually been triggered already
sub->_process_env();
}
}
}
Expand Down Expand Up @@ -1482,11 +1480,12 @@ CLI11_INLINE bool App::_parse_single_config(const ConfigItem &item, std::size_t

if(op == nullptr) {
// If the option was not present
if(get_allow_config_extras() == config_extras_mode::capture)
if(get_allow_config_extras() == config_extras_mode::capture) {
// Should we worry about classifying the extras properly?
missing_.emplace_back(detail::Classifier::NONE, item.fullname());
for(const auto &input : item.inputs) {
missing_.emplace_back(detail::Classifier::NONE, input);
for(const auto &input : item.inputs) {
missing_.emplace_back(detail::Classifier::NONE, input);
}
}
return false;
}
Expand Down
21 changes: 20 additions & 1 deletion tests/ConfigFileTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,26 @@ TEST_CASE_METHOD(TApp, "IniGetRemainingOption", "[config]") {
int two{0};
app.add_option("--two", two);
REQUIRE_NOTHROW(run());
std::vector<std::string> ExpectedRemaining = {ExtraOption, "3"};
std::vector<std::string> ExpectedRemaining = {ExtraOption, ExtraOptionValue};
CHECK(ExpectedRemaining == app.remaining());
}

TEST_CASE_METHOD(TApp, "IniIgnoreRemainingOption", "[config]") {
TempFile tmpini{"TestIniTmp.ini"};

app.set_config("--config", tmpini);
app.allow_config_extras(CLI::config_extras_mode::ignore);

{
std::ofstream out{tmpini};
out << "three=3\n";
out << "two=99\n";
}

int two{0};
app.add_option("--two", two);
REQUIRE_NOTHROW(run());
std::vector<std::string> ExpectedRemaining = {};
CHECK(ExpectedRemaining == app.remaining());
}

Expand Down
Loading