mirror of
https://github.com/spf13/cobra
synced 2024-12-29 15:57:10 +00:00
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
1 changed files with 3 additions and 2 deletions
|
@ -95,7 +95,7 @@ func (cmd *Command) GenMan(header *GenManHeader, out *bytes.Buffer) {
|
|||
|
||||
func fillHeader(header *GenManHeader, name string) {
|
||||
if header.Title == "" {
|
||||
header.Title = name
|
||||
header.Title = strings.ToUpper(strings.Replace(name, " ", "\\-", -1))
|
||||
}
|
||||
if header.Section == "" {
|
||||
header.Section = "1"
|
||||
|
@ -168,12 +168,13 @@ func manPrintOptions(out *bytes.Buffer, command *Command) {
|
|||
}
|
||||
|
||||
func genMarkdown(cmd *Command, header *GenManHeader) []byte {
|
||||
fillHeader(header, cmd.Name())
|
||||
// something like `rootcmd subcmd1 subcmd2`
|
||||
commandName := cmd.CommandPath()
|
||||
// something like `rootcmd-subcmd1-subcmd2`
|
||||
dashCommandName := strings.Replace(commandName, " ", "-", -1)
|
||||
|
||||
fillHeader(header, commandName)
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
|
||||
short := cmd.Short
|
||||
|
|
Loading…
Reference in a new issue