Skip to content

Commit 7d74b97

Browse files
committed
Fix:(issue_1860) Remove hidden flags from flag categories
1 parent 094a9bc commit 7d74b97

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

category.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func newFlagCategoriesFromFlags(fs []Flag) FlagCategories {
104104
var categorized bool
105105
for _, fl := range fs {
106106
if cf, ok := fl.(CategorizableFlag); ok {
107-
if cat := cf.GetCategory(); cat != "" {
107+
if cat := cf.GetCategory(); cat != "" && cf.IsVisible() {
108108
fc.AddFlag(cat, cf)
109109
categorized = true
110110
}
@@ -114,7 +114,7 @@ func newFlagCategoriesFromFlags(fs []Flag) FlagCategories {
114114
if categorized {
115115
for _, fl := range fs {
116116
if cf, ok := fl.(CategorizableFlag); ok {
117-
if cf.GetCategory() == "" {
117+
if cf.GetCategory() == "" && cf.IsVisible() {
118118
fc.AddFlag("", fl)
119119
}
120120
}

command_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,11 @@ func TestCommand_VisibleFlagCategories(t *testing.T) {
466466
Aliases: []string{"altd1", "altd2"},
467467
Category: "cat1",
468468
},
469+
&StringFlag{
470+
Name: "sfd",
471+
Category: "cat2",
472+
Hidden: true,
473+
},
469474
},
470475
}
471476

0 commit comments

Comments
 (0)