aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/spf13/cobra/doc
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/spf13/cobra/doc')
-rw-r--r--vendor/github.com/spf13/cobra/doc/man_docs.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/vendor/github.com/spf13/cobra/doc/man_docs.go b/vendor/github.com/spf13/cobra/doc/man_docs.go
index baa48118..4a062339 100644
--- a/vendor/github.com/spf13/cobra/doc/man_docs.go
+++ b/vendor/github.com/spf13/cobra/doc/man_docs.go
@@ -20,6 +20,7 @@ import (
"os"
"path/filepath"
"sort"
+ "strconv"
"strings"
"time"
@@ -87,7 +88,7 @@ type GenManTreeOptions struct {
// GenManHeader is a lot like the .TH header at the start of man pages. These
// include the title, section, date, source, and manual. We will use the
-// current time if Date if unset and will use "Auto generated by spf13/cobra"
+// current time if Date is unset and will use "Auto generated by spf13/cobra"
// if the Source is unset.
type GenManHeader struct {
Title string
@@ -104,14 +105,16 @@ func GenMan(cmd *cobra.Command, header *GenManHeader, w io.Writer) error {
if header == nil {
header = &GenManHeader{}
}
- fillHeader(header, cmd.CommandPath())
+ if err := fillHeader(header, cmd.CommandPath()); err != nil {
+ return err
+ }
b := genMan(cmd, header)
_, err := w.Write(md2man.Render(b))
return err
}
-func fillHeader(header *GenManHeader, name string) {
+func fillHeader(header *GenManHeader, name string) error {
if header.Title == "" {
header.Title = strings.ToUpper(strings.Replace(name, " ", "\\-", -1))
}
@@ -120,12 +123,20 @@ func fillHeader(header *GenManHeader, name string) {
}
if header.Date == nil {
now := time.Now()
+ if epoch := os.Getenv("SOURCE_DATE_EPOCH"); epoch != "" {
+ unixEpoch, err := strconv.ParseInt(epoch, 10, 64)
+ if err != nil {
+ return fmt.Errorf("invalid SOURCE_DATE_EPOCH: %v", err)
+ }
+ now = time.Unix(unixEpoch, 0)
+ }
header.Date = &now
}
header.date = (*header.Date).Format("Jan 2006")
if header.Source == "" {
header.Source = "Auto generated by spf13/cobra"
}
+ return nil
}
func manPreamble(buf *bytes.Buffer, header *GenManHeader, cmd *cobra.Command, dashedName string) {