forked from mirror/cobra
Ensure man page title is uppercase and has rootcmd
As described in http://man7.org/linux/man-pages/man7/man-pages.7.html
This commit is contained in:
parent
baf44a3923
commit
3bd84ba55c
|
@ -95,7 +95,7 @@ func (cmd *Command) GenMan(header *GenManHeader, out *bytes.Buffer) {
|
||||||
|
|
||||||
func fillHeader(header *GenManHeader, name string) {
|
func fillHeader(header *GenManHeader, name string) {
|
||||||
if header.Title == "" {
|
if header.Title == "" {
|
||||||
header.Title = name
|
header.Title = strings.ToUpper(strings.Replace(name, " ", "\\-", -1))
|
||||||
}
|
}
|
||||||
if header.Section == "" {
|
if header.Section == "" {
|
||||||
header.Section = "1"
|
header.Section = "1"
|
||||||
|
@ -168,12 +168,13 @@ func manPrintOptions(out *bytes.Buffer, command *Command) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func genMarkdown(cmd *Command, header *GenManHeader) []byte {
|
func genMarkdown(cmd *Command, header *GenManHeader) []byte {
|
||||||
fillHeader(header, cmd.Name())
|
|
||||||
// something like `rootcmd subcmd1 subcmd2`
|
// something like `rootcmd subcmd1 subcmd2`
|
||||||
commandName := cmd.CommandPath()
|
commandName := cmd.CommandPath()
|
||||||
// something like `rootcmd-subcmd1-subcmd2`
|
// something like `rootcmd-subcmd1-subcmd2`
|
||||||
dashCommandName := strings.Replace(commandName, " ", "-", -1)
|
dashCommandName := strings.Replace(commandName, " ", "-", -1)
|
||||||
|
|
||||||
|
fillHeader(header, commandName)
|
||||||
|
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
|
|
||||||
short := cmd.Short
|
short := cmd.Short
|
||||||
|
|
Loading…
Reference in New Issue