MCPcopy Index your code
hub / github.com/cli/cli / fillHeader

Function fillHeader

internal/docs/man.go:107–126  ·  view source on GitHub ↗
(header *GenManHeader, name string)

Source from the content-addressed store, hash-verified

105}
106
107func 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
128func manPreamble(buf *bytes.Buffer, header *GenManHeader, cmd *cobra.Command, dashedName string) {
129 buf.WriteString(fmt.Sprintf(`%% "%s" "%s" "%s" "%s" "%s"

Callers 1

renderManFunction · 0.85

Calls 2

ReplaceMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected