Skip to content

--help prints out [flags] even when all flags are required #508

@ericnorris

Description

@ericnorris
func main() {
    var args struct {
        One string `required:""`
    }

    kong.Parse(&args)
}

Outputs:

Usage: test --one=STRING [flags]

Flags:
  -h, --help          Show context-sensitive help.
      --one=STRING

I would expect that Kong would not print the trailing [flags], since there are no other expected flags. I believe this is happening because the --help flag is optional and considered when deciding to print out the [flags] summary:

kong/model.go

Lines 169 to 174 in 5b36573

for _, flag := range allFlags {
if !flag.Required {
summary += " [flags]"
break
}
}

It's minor, but it feels like it's implying there are other flags, when there aren't.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions