mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-29 20:23:55 +00:00
parent
821940c368
commit
f583e5baf6
@ -999,8 +999,11 @@ class App {
|
|||||||
bool config_required = false) {
|
bool config_required = false) {
|
||||||
|
|
||||||
// Remove existing config if present
|
// Remove existing config if present
|
||||||
if(config_ptr_ != nullptr)
|
if(config_ptr_ != nullptr) {
|
||||||
remove_option(config_ptr_);
|
remove_option(config_ptr_);
|
||||||
|
config_name_ = "";
|
||||||
|
config_required_ = false; // Not really needed, but complete
|
||||||
|
}
|
||||||
|
|
||||||
// Only add config if option passed
|
// Only add config if option passed
|
||||||
if(!option_name.empty()) {
|
if(!option_name.empty()) {
|
||||||
|
@ -889,3 +889,24 @@ TEST_F(TApp, DefaultsIniQuotedOutput) {
|
|||||||
EXPECT_THAT(str, HasSubstr("val1=\"I am a string\""));
|
EXPECT_THAT(str, HasSubstr("val1=\"I am a string\""));
|
||||||
EXPECT_THAT(str, HasSubstr("val2='I am a \"confusing\" string'"));
|
EXPECT_THAT(str, HasSubstr("val2='I am a \"confusing\" string'"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #298
|
||||||
|
TEST_F(TApp, StopReadingConfigOnClear) {
|
||||||
|
|
||||||
|
TempFile tmpini{"TestIniTmp.ini"};
|
||||||
|
|
||||||
|
app.set_config("--config", tmpini);
|
||||||
|
app.set_config(); // Should *not* read config file
|
||||||
|
|
||||||
|
{
|
||||||
|
std::ofstream out{tmpini};
|
||||||
|
out << "volume=1" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
int volume = 0;
|
||||||
|
app.add_option("--volume", volume, "volume1");
|
||||||
|
|
||||||
|
run();
|
||||||
|
|
||||||
|
EXPECT_EQ(volume, 0);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user