| 105 | } |
| 106 | |
| 107 | func fillHeader(header *GenManHeader, name string) error { |
| 108 | if header.Title == "" { |
| 109 | header.Title = strings.ToUpper(strings.Replace(name, " ", "\\-", -1)) |
| 110 | } |
| 111 | if header.Section == "" { |
| 112 | header.Section = "1" |
| 113 | } |
| 114 | if header.Date == nil { |
| 115 | now := time.Now() |
| 116 | if epoch := os.Getenv("SOURCE_DATE_EPOCH"); epoch != "" { |
| 117 | unixEpoch, err := strconv.ParseInt(epoch, 10, 64) |
| 118 | if err != nil { |
| 119 | return fmt.Errorf("invalid SOURCE_DATE_EPOCH: %v", err) |
| 120 | } |
| 121 | now = time.Unix(unixEpoch, 0) |
| 122 | } |
| 123 | header.Date = &now |
| 124 | } |
| 125 | return nil |
| 126 | } |
| 127 | |
| 128 | func manPreamble(buf *bytes.Buffer, header *GenManHeader, cmd *cobra.Command, dashedName string) { |
| 129 | buf.WriteString(fmt.Sprintf(`%% "%s" "%s" "%s" "%s" "%s" |