Output the inherited and non-inherited flags in the man page
This commit is contained in:
parent
d508395828
commit
aab9cc3219
@ -100,18 +100,18 @@ func printFlags(out *bytes.Buffer, flags *pflag.FlagSet) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printOptions(out *bytes.Buffer, command *cobra.Command) {
|
func printOptions(out *bytes.Buffer, command *cobra.Command) {
|
||||||
var flags *pflag.FlagSet
|
flags := command.NonInheritedFlags()
|
||||||
if command.HasFlags() {
|
if flags.HasFlags() {
|
||||||
flags = command.Flags()
|
fmt.Fprintf(out, "# OPTIONS\n")
|
||||||
} else if !command.HasParent() && command.HasPersistentFlags() {
|
printFlags(out, flags)
|
||||||
flags = command.PersistentFlags()
|
fmt.Fprintf(out, "\n")
|
||||||
}
|
}
|
||||||
if flags == nil {
|
flags = command.InheritedFlags()
|
||||||
return
|
if flags.HasFlags() {
|
||||||
|
fmt.Fprintf(out, "# OPTIONS INHERITED FROM PARENT COMMANDS\n")
|
||||||
|
printFlags(out, flags)
|
||||||
|
fmt.Fprintf(out, "\n")
|
||||||
}
|
}
|
||||||
fmt.Fprintf(out, "# OPTIONS\n")
|
|
||||||
printFlags(out, flags)
|
|
||||||
fmt.Fprintf(out, "\n")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func genMarkdown(command *cobra.Command, parent, docsDir string) {
|
func genMarkdown(command *cobra.Command, parent, docsDir string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user