From 9c32fb42ec6b8a3c8dccc0ac8dc099bd750cce5d Mon Sep 17 00:00:00 2001 From: Anthony Fok Date: Sat, 21 Nov 2015 06:18:37 -0700 Subject: [PATCH] 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. --- man_docs.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/man_docs.go b/man_docs.go index 36bbf26..3e852f7 100644 --- a/man_docs.go +++ b/man_docs.go @@ -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)