mirror of https://github.com/spf13/cobra.git
Reset man page title when necessary in GenManTree
If the user did not define header.Title when calling GenManTree(), reset it after each call to GenMan(), otherwise the entire man page tree would be stuck with the full command name that was calculated for the first man page, leaving all subsequent man pages with an identical but incorrect title.
This commit is contained in:
parent
3bd84ba55c
commit
9c32fb42ec
|
@ -47,8 +47,14 @@ func (cmd *Command) GenManTree(header *GenManHeader, dir string) {
|
||||||
}
|
}
|
||||||
out := new(bytes.Buffer)
|
out := new(bytes.Buffer)
|
||||||
|
|
||||||
|
needToResetTitle := header.Title == ""
|
||||||
|
|
||||||
cmd.GenMan(header, out)
|
cmd.GenMan(header, out)
|
||||||
|
|
||||||
|
if needToResetTitle {
|
||||||
|
header.Title = ""
|
||||||
|
}
|
||||||
|
|
||||||
filename := cmd.CommandPath()
|
filename := cmd.CommandPath()
|
||||||
filename = dir + strings.Replace(filename, " ", "-", -1) + ".1"
|
filename = dir + strings.Replace(filename, " ", "-", -1) + ".1"
|
||||||
outFile, err := os.Create(filename)
|
outFile, err := os.Create(filename)
|
||||||
|
|
Loading…
Reference in New Issue