skip print section flags if no flags

pull/8/head
stewart-yu 2018-08-17 17:20:05 +08:00
parent a14673cfbd
commit 01195efbe3
1 changed files with 3 additions and 0 deletions

View File

@ -52,6 +52,9 @@ func (nfs *NamedFlagSets) FlagSet(name string) *pflag.FlagSet {
func PrintSections(w io.Writer, fss NamedFlagSets, cols int) {
for _, name := range fss.Order {
fs := fss.FlagSets[name]
if !fs.HasFlags() {
continue
}
wideFS := pflag.NewFlagSet("", pflag.ExitOnError)
wideFS.AddFlagSet(fs)