From ce59deb7b3a77a5b29ac4d768f9f8ffb530e4882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Tue, 16 Jun 2020 13:58:31 +0200 Subject: [PATCH] Show inherited flags in help output --- command/help.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/command/help.go b/command/help.go index 87e302839..cf9b64b7a 100644 --- a/command/help.go +++ b/command/help.go @@ -95,6 +95,11 @@ func rootHelpFunc(command *cobra.Command, args []string) { dedent := regexp.MustCompile(`(?m)^ `) helpEntries = append(helpEntries, helpEntry{"FLAGS", dedent.ReplaceAllString(flagUsages, "")}) } + inheritedFlagUsages := command.InheritedFlags().FlagUsages() + if inheritedFlagUsages != "" { + dedent := regexp.MustCompile(`(?m)^ `) + helpEntries = append(helpEntries, helpEntry{"INHERITED FLAGS", dedent.ReplaceAllString(inheritedFlagUsages, "")}) + } if _, ok := command.Annotations["help:arguments"]; ok { helpEntries = append(helpEntries, helpEntry{"ARGUMENTS", command.Annotations["help:arguments"]}) }