Skip to content

Commit

Permalink
Fix:(issue_1860) Remove hidden flags from flag categories
Browse files Browse the repository at this point in the history
  • Loading branch information
dearchap committed Feb 17, 2024
1 parent 094a9bc commit 7d74b97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions category.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func newFlagCategoriesFromFlags(fs []Flag) FlagCategories {
var categorized bool
for _, fl := range fs {
if cf, ok := fl.(CategorizableFlag); ok {
if cat := cf.GetCategory(); cat != "" {
if cat := cf.GetCategory(); cat != "" && cf.IsVisible() {
fc.AddFlag(cat, cf)
categorized = true
}
Expand All @@ -114,7 +114,7 @@ func newFlagCategoriesFromFlags(fs []Flag) FlagCategories {
if categorized {
for _, fl := range fs {
if cf, ok := fl.(CategorizableFlag); ok {
if cf.GetCategory() == "" {
if cf.GetCategory() == "" && cf.IsVisible() {
fc.AddFlag("", fl)
}
}
Expand Down
5 changes: 5 additions & 0 deletions command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ func TestCommand_VisibleFlagCategories(t *testing.T) {
Aliases: []string{"altd1", "altd2"},
Category: "cat1",
},
&StringFlag{
Name: "sfd",
Category: "cat2",
Hidden: true,
},
},
}

Expand Down

0 comments on commit 7d74b97

Please sign in to comment.