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:
Anthony Fok 2015-11-21 06:18:37 -07:00
parent 3bd84ba55c
commit 9c32fb42ec

View file

@ -47,8 +47,14 @@ func (cmd *Command) GenManTree(header *GenManHeader, dir string) {
}
out := new(bytes.Buffer)
needToResetTitle := header.Title == ""
cmd.GenMan(header, out)
if needToResetTitle {
header.Title = ""
}
filename := cmd.CommandPath()
filename = dir + strings.Replace(filename, " ", "-", -1) + ".1"
outFile, err := os.Create(filename)