diff --git a/include/CLI/App.hpp b/include/CLI/App.hpp index a98352c5..1cca625c 100644 --- a/include/CLI/App.hpp +++ b/include/CLI/App.hpp @@ -810,8 +810,8 @@ class App { std::stringstream out; for(const Option_p &opt : options_) { - // Only process option with a long-name - if(!opt->lnames_.empty()) { + // Only process option with a long-name and configurable + if(!opt->lnames_.empty() && opt->get_configurable()) { std::string name = prefix + opt->lnames_[0]; // Non-flags diff --git a/tests/IniTest.cpp b/tests/IniTest.cpp index 695b3c26..1e032cc7 100644 --- a/tests/IniTest.cpp +++ b/tests/IniTest.cpp @@ -561,6 +561,20 @@ TEST_F(TApp, IniOutputSimple) { EXPECT_EQ("simple=3\n", str); } +TEST_F(TApp, IniOutputNoConfigurable) { + + int v1, v2; + app.add_option("--simple", v1); + app.add_option("--noconf", v2)->configurable(false); + + args = {"--simple=3", "--noconf=2"}; + + run(); + + std::string str = app.config_to_str(); + EXPECT_EQ("simple=3\n", str); +} + TEST_F(TApp, IniOutputVector) { std::vector v;