From 1f510725e52d2e61af9af71b71a2dc24c916c75a Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Tue, 14 Feb 2017 12:21:11 -0500 Subject: [PATCH] Remove flags from inifile --- CHANGELOG.md | 1 + include/CLI/App.hpp | 2 +- tests/IniTest.cpp | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5672d3c6..7d4a8b8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Version 0.5 (in progress) * Added `require_subcommand` to `App`, to simplify forcing subcommands. Do not "chain" with `add_subcommand`, since that is the subcommand, not the master `App`. Untested. +* Added printout of ini file text given parsed options, skips flags. ## Version 0.4 diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 9feae078..729c77c8 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -105,7 +105,7 @@ public: std::string config_to_str() const { std::stringstream out; for(const Option_p &opt : options) { - if(opt->lnames.size() > 0 && opt->count() > 0) + if(opt->lnames.size() > 0 && opt->count() > 0 && opt->get_expected() > 0) out << opt->lnames[0] << "=" << detail::join(opt->flatten_results()) << std::endl; } return out.str(); diff --git a/tests/IniTest.cpp b/tests/IniTest.cpp index d7de9e17..c1e688e9 100644 --- a/tests/IniTest.cpp +++ b/tests/IniTest.cpp @@ -5,6 +5,7 @@ #include "gmock/gmock.h" using ::testing::HasSubstr; +using ::testing::Not; TEST(StringBased, First) { std::stringstream ofile; @@ -165,6 +166,6 @@ TEST_F(TApp, IniOutputFlag) { std::string str = app.config_to_str(); EXPECT_THAT(str, HasSubstr("simple=3")); - EXPECT_THAT(str, HasSubstr("nothing=")); + EXPECT_THAT(str, Not(HasSubstr("nothing="))); }