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:
parent
a687eb9587
commit
2bea3983c0
@ -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) {
|
||||
|
||||
|
@ -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")));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user