MCPcopy Index your code
hub / github.com/ContainerSSH/ContainerSSH / generateMessageCodesFile

Function generateMessageCodesFile

cmd/generate-message-codes/main.go:119–136  ·  view source on GitHub ↗

generateMessageCodesFile generates the contents of the CODES.md file and returns them.

(filename string, title string)

Source from the content-addressed store, hash-verified

117
118// generateMessageCodesFile generates the contents of the CODES.md file and returns them.
119func generateMessageCodesFile(filename string, title string) (string, error) {
120 codes, err := getMessageCodes(filename)
121 if err != nil {
122 return "", err
123 }
124 tpl, err := template.New("CODES.md.tpl").Parse(messageFileTemplate)
125 if err != nil {
126 return "", fmt.Errorf("bug: failed to parse template (%w)", err)
127 }
128 wr := &bytes.Buffer{}
129 if err := tpl.Execute(wr, &tplData{
130 Title: title,
131 Codes: codes,
132 }); err != nil {
133 return "", fmt.Errorf("failed to render codes template (%w)", err)
134 }
135 return wr.String(), nil
136}
137
138// writeMessageCodesFile generates and writes the CODES.md file
139func writeMessageCodesFile(data []byte, destinationFile string) error {

Callers 1

mainFunction · 0.85

Calls 3

getMessageCodesFunction · 0.85
ErrorfMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected