Ensure SEE ALSO list has no leading comma, fixing #229
This commit is contained in:
parent
8e91712f17
commit
cb8496d6b2
@ -188,10 +188,12 @@ func genMan(cmd *cobra.Command, header *GenManHeader) []byte {
|
|||||||
}
|
}
|
||||||
if hasSeeAlso(cmd) {
|
if hasSeeAlso(cmd) {
|
||||||
fmt.Fprintf(buf, "# SEE ALSO\n")
|
fmt.Fprintf(buf, "# SEE ALSO\n")
|
||||||
|
seealsos := make([]string, 0)
|
||||||
if cmd.HasParent() {
|
if cmd.HasParent() {
|
||||||
parentPath := cmd.Parent().CommandPath()
|
parentPath := cmd.Parent().CommandPath()
|
||||||
dashParentPath := strings.Replace(parentPath, " ", "-", -1)
|
dashParentPath := strings.Replace(parentPath, " ", "-", -1)
|
||||||
fmt.Fprintf(buf, "**%s(%s)**", dashParentPath, header.Section)
|
seealso := fmt.Sprintf("**%s(%s)**", dashParentPath, header.Section)
|
||||||
|
seealsos = append(seealsos, seealso)
|
||||||
cmd.VisitParents(func(c *cobra.Command) {
|
cmd.VisitParents(func(c *cobra.Command) {
|
||||||
if c.DisableAutoGenTag {
|
if c.DisableAutoGenTag {
|
||||||
cmd.DisableAutoGenTag = c.DisableAutoGenTag
|
cmd.DisableAutoGenTag = c.DisableAutoGenTag
|
||||||
@ -200,16 +202,14 @@ func genMan(cmd *cobra.Command, header *GenManHeader) []byte {
|
|||||||
}
|
}
|
||||||
children := cmd.Commands()
|
children := cmd.Commands()
|
||||||
sort.Sort(byName(children))
|
sort.Sort(byName(children))
|
||||||
for i, c := range children {
|
for _, c := range children {
|
||||||
if !c.IsAvailableCommand() || c.IsHelpCommand() {
|
if !c.IsAvailableCommand() || c.IsHelpCommand() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if cmd.HasParent() || i > 0 {
|
seealso := fmt.Sprintf("**%s-%s(%s)**", dashCommandName, c.Name(), header.Section)
|
||||||
fmt.Fprintf(buf, ", ")
|
seealsos = append(seealsos, seealso)
|
||||||
}
|
|
||||||
fmt.Fprintf(buf, "**%s-%s(%s)**", dashCommandName, c.Name(), header.Section)
|
|
||||||
}
|
}
|
||||||
fmt.Fprintf(buf, "\n")
|
fmt.Fprintf(buf, "%s\n", strings.Join(seealsos, ", "))
|
||||||
}
|
}
|
||||||
if !cmd.DisableAutoGenTag {
|
if !cmd.DisableAutoGenTag {
|
||||||
fmt.Fprintf(buf, "# HISTORY\n%s Auto generated by spf13/cobra\n", header.Date.Format("2-Jan-2006"))
|
fmt.Fprintf(buf, "# HISTORY\n%s Auto generated by spf13/cobra\n", header.Date.Format("2-Jan-2006"))
|
||||||
|
Loading…
Reference in New Issue
Block a user