diff --git a/include/CLI/Option.hpp b/include/CLI/Option.hpp index 1647617c..ee74929a 100644 --- a/include/CLI/Option.hpp +++ b/include/CLI/Option.hpp @@ -433,6 +433,10 @@ class Option { /// Set the default value string representation void set_default_val(std::string val) { defaultval_ = val; } + + /// Set the type name displayed on this option + void set_type_name(std::string val) {typeval_ = val;} + ///@} protected: diff --git a/tests/HelpTest.cpp b/tests/HelpTest.cpp index ac42ad05..863f4225 100644 --- a/tests/HelpTest.cpp +++ b/tests/HelpTest.cpp @@ -190,6 +190,22 @@ TEST(THelp, ExcludesPositional) { EXPECT_THAT(help, HasSubstr("Excludes: op1")); } +TEST(THelp, ManualSetters) { + + CLI::App app{"My prog"}; + + int x; + + CLI::Option *op1 = app.add_option("--op", x); + op1->set_default_val("12"); + op1->set_type_name("BIGGLES"); + + std::string help = app.help(); + + EXPECT_THAT(help, HasSubstr("=12")); + EXPECT_THAT(help, HasSubstr("BIGGLES")); +} + TEST(THelp, Subcom) { CLI::App app{"My prog"};