diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index 8249703d..8516bcdf 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -809,7 +809,8 @@ class App { /// Produce a string that could be read in as a config of the current values of the App. Set default_also to include /// default arguments. Prefix will add a string to the beginning of each option. - std::string config_to_str(bool default_also = false, std::string prefix = "", bool write_description = false) const { + std::string + config_to_str(bool default_also = false, std::string prefix = "", bool write_description = false) const { std::stringstream out; for(const Option_p &opt : options_) { @@ -840,10 +841,10 @@ class App { } else if(opt->count() == 0 && default_also) { value = "false"; } - - if (value.size() != 0) { - if (write_description && opt->has_description()) { - if (out.tellp() != 0) { + + if(value.size() != 0) { + if(write_description && opt->has_description()) { + if(out.tellp() != 0) { out << std::endl; } out << "; " << opt->get_description() << std::endl; diff --git a/tests/IniTest.cpp b/tests/IniTest.cpp index 53d70627..2021e34a 100644 --- a/tests/IniTest.cpp +++ b/tests/IniTest.cpp @@ -576,14 +576,14 @@ TEST_F(TApp, IniOutputNoConfigurable) { } TEST_F(TApp, IniOutputShortSingleDescription) { - std::string flag = "some_flag"; - std::string description = "Some short description."; - app.add_flag("--" + flag, description); - - run(); - - std::string str = app.config_to_str(true, "", true); - EXPECT_THAT(str, HasSubstr("; " + description + "\n" + flag + "=false\n")); + std::string flag = "some_flag"; + std::string description = "Some short description."; + app.add_flag("--" + flag, description); + + run(); + + std::string str = app.config_to_str(true, "", true); + EXPECT_THAT(str, HasSubstr("; " + description + "\n" + flag + "=false\n")); } TEST_F(TApp, IniOutputShortDoubleDescription) { @@ -593,9 +593,9 @@ TEST_F(TApp, IniOutputShortDoubleDescription) { std::string description2 = "Second description."; app.add_flag("--" + flag1, description1); app.add_flag("--" + flag2, description2); - + run(); - + std::string str = app.config_to_str(true, "", true); EXPECT_EQ(str, "; " + description1 + "\n" + flag1 + "=false\n\n; " + description2 + "\n" + flag2 + "=false\n"); }