From 68207bdcc1a55fe15e5cf955d8d61ca68d43988b Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Thu, 30 Nov 2017 09:34:45 -0500 Subject: [PATCH] Removing non-configurable from config_to_str --- include/CLI/App.hpp | 4 ++-- tests/IniTest.cpp | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) 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;