mirror of
https://github.com/spf13/cobra
synced 2025-05-07 22:07:23 +00:00
Man pages wont have auto gen tag when option is disabled
- this addresses #741
This commit is contained in:
parent
11ba63fc3b
commit
2c0b6931d0
2 changed files with 5 additions and 3 deletions
|
@ -105,7 +105,7 @@ func GenMan(cmd *cobra.Command, header *GenManHeader, w io.Writer) error {
|
||||||
if header == nil {
|
if header == nil {
|
||||||
header = &GenManHeader{}
|
header = &GenManHeader{}
|
||||||
}
|
}
|
||||||
if err := fillHeader(header, cmd.CommandPath()); err != nil {
|
if err := fillHeader(header, cmd.CommandPath(), cmd.DisableAutoGenTag); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ func GenMan(cmd *cobra.Command, header *GenManHeader, w io.Writer) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func fillHeader(header *GenManHeader, name string) error {
|
func fillHeader(header *GenManHeader, name string, disableAutoGen bool) error {
|
||||||
if header.Title == "" {
|
if header.Title == "" {
|
||||||
header.Title = strings.ToUpper(strings.Replace(name, " ", "\\-", -1))
|
header.Title = strings.ToUpper(strings.Replace(name, " ", "\\-", -1))
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ func fillHeader(header *GenManHeader, name string) error {
|
||||||
header.Date = &now
|
header.Date = &now
|
||||||
}
|
}
|
||||||
header.date = (*header.Date).Format("Jan 2006")
|
header.date = (*header.Date).Format("Jan 2006")
|
||||||
if header.Source == "" {
|
if header.Source == "" && !disableAutoGen {
|
||||||
header.Source = "Auto generated by spf13/cobra"
|
header.Source = "Auto generated by spf13/cobra"
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -101,6 +101,8 @@ func TestGenManNoGenTag(t *testing.T) {
|
||||||
|
|
||||||
unexpected := translate("#HISTORY")
|
unexpected := translate("#HISTORY")
|
||||||
checkStringOmits(t, output, unexpected)
|
checkStringOmits(t, output, unexpected)
|
||||||
|
unexpected = translate("Auto generated by spf13/cobra")
|
||||||
|
checkStringOmits(t, output, unexpected)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGenManSeeAlso(t *testing.T) {
|
func TestGenManSeeAlso(t *testing.T) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue