Commit 68207bdcc1a55fe15e5cf955d8d61ca68d43988b
1 parent
93a16eea
Removing non-configurable from config_to_str
Showing
2 changed files
with
16 additions
and
2 deletions
include/CLI/App.hpp
| @@ -810,8 +810,8 @@ class App { | @@ -810,8 +810,8 @@ class App { | ||
| 810 | std::stringstream out; | 810 | std::stringstream out; |
| 811 | for(const Option_p &opt : options_) { | 811 | for(const Option_p &opt : options_) { |
| 812 | 812 | ||
| 813 | - // Only process option with a long-name | ||
| 814 | - if(!opt->lnames_.empty()) { | 813 | + // Only process option with a long-name and configurable |
| 814 | + if(!opt->lnames_.empty() && opt->get_configurable()) { | ||
| 815 | std::string name = prefix + opt->lnames_[0]; | 815 | std::string name = prefix + opt->lnames_[0]; |
| 816 | 816 | ||
| 817 | // Non-flags | 817 | // Non-flags |
tests/IniTest.cpp
| @@ -561,6 +561,20 @@ TEST_F(TApp, IniOutputSimple) { | @@ -561,6 +561,20 @@ TEST_F(TApp, IniOutputSimple) { | ||
| 561 | EXPECT_EQ("simple=3\n", str); | 561 | EXPECT_EQ("simple=3\n", str); |
| 562 | } | 562 | } |
| 563 | 563 | ||
| 564 | +TEST_F(TApp, IniOutputNoConfigurable) { | ||
| 565 | + | ||
| 566 | + int v1, v2; | ||
| 567 | + app.add_option("--simple", v1); | ||
| 568 | + app.add_option("--noconf", v2)->configurable(false); | ||
| 569 | + | ||
| 570 | + args = {"--simple=3", "--noconf=2"}; | ||
| 571 | + | ||
| 572 | + run(); | ||
| 573 | + | ||
| 574 | + std::string str = app.config_to_str(); | ||
| 575 | + EXPECT_EQ("simple=3\n", str); | ||
| 576 | +} | ||
| 577 | + | ||
| 564 | TEST_F(TApp, IniOutputVector) { | 578 | TEST_F(TApp, IniOutputVector) { |
| 565 | 579 | ||
| 566 | std::vector<int> v; | 580 | std::vector<int> v; |