1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-30 12:43:52 +00:00

Futher improvement for #12, can change type str

This commit is contained in:
Henry Fredrick Schreiner 2017-06-05 08:58:01 -04:00
parent 04268dac5a
commit e3423bb5ad
2 changed files with 20 additions and 0 deletions

View File

@ -433,6 +433,10 @@ class Option {
/// Set the default value string representation /// Set the default value string representation
void set_default_val(std::string val) { defaultval_ = val; } 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: protected:

View File

@ -190,6 +190,22 @@ TEST(THelp, ExcludesPositional) {
EXPECT_THAT(help, HasSubstr("Excludes: op1")); 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) { TEST(THelp, Subcom) {
CLI::App app{"My prog"}; CLI::App app{"My prog"};