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

Return empty string in Option::get_name() for hidden options (#333)

* Return empty string in Option::get_name() for hidden options

Fixes https://github.com/CLIUtils/CLI11/issues/332

* Remove to_lower() call

* Formatting

* Fix THelp.Hidden
This commit is contained in:
Kannan 2019-10-27 11:53:27 -06:00 committed by Henry Schreiner
parent a687eb9587
commit 2bea3983c0
2 changed files with 3 additions and 1 deletions

View File

@ -652,6 +652,8 @@ class Option : public OptionBase<Option> {
std::string get_name(bool positional = false, //<[input] Show the positional name
bool all_options = false //<[input] Show every option
) const {
if(get_group().empty())
return {}; // Hidden
if(all_options) {

View File

@ -92,7 +92,7 @@ TEST(THelp, Hidden) {
EXPECT_THAT(help, HasSubstr("My prog"));
EXPECT_THAT(help, HasSubstr("-h,--help"));
EXPECT_THAT(help, HasSubstr("Options:"));
EXPECT_THAT(help, HasSubstr("[something]"));
EXPECT_THAT(help, Not(HasSubstr("[something]")));
EXPECT_THAT(help, Not(HasSubstr("something ")));
EXPECT_THAT(help, Not(HasSubstr("another")));
}