From ae5bf0ce62ec47cb0a360e56c3895c30ecc7b28d Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 30 Mar 2017 15:49:40 -0400 Subject: [PATCH] Adding =false when printing config with defaults --- include/CLI/App.hpp | 5 +++++ tests/IniTest.cpp | 3 +++ 2 files changed, 8 insertions(+) diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index e37d53f1..41b78dee 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -573,7 +573,12 @@ public: // Flag, multiple passed } else if(opt->count() > 1) { out << name << "=" << opt->count() << std::endl; + + // Flag, not present + } else if(opt->count() == 0 && default_also) { + out << name << "=false" << std::endl; } + } } for(const App_p &subcom : subcommands_) diff --git a/tests/IniTest.cpp b/tests/IniTest.cpp index 934d727c..8fb8e96a 100644 --- a/tests/IniTest.cpp +++ b/tests/IniTest.cpp @@ -520,6 +520,9 @@ TEST_F(TApp, IniOutputFlag) { EXPECT_THAT(str, Not(HasSubstr("nothing"))); EXPECT_THAT(str, HasSubstr("onething=true")); EXPECT_THAT(str, HasSubstr("something=2")); + + std::string str = app.config_to_str(true); + EXPECT_THAT(str, HasSubstr("nothing")); } TEST_F(TApp, IniOutputSet) {