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
1 changed files with 6 additions and 0 deletions

View File

@ -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)