MCPcopy Create free account
hub / github.com/cli/cli / Serialize

Function Serialize

internal/skills/frontmatter/frontmatter.go:138–157  ·  view source on GitHub ↗

Serialize writes a frontmatter map and body back to a SKILL.md string.

(frontmatter map[string]any, body string)

Source from the content-addressed store, hash-verified

136
137// Serialize writes a frontmatter map and body back to a SKILL.md string.
138func Serialize(frontmatter map[string]any, body string) (string, error) {
139 var buf bytes.Buffer
140
141 yamlBytes, err := yaml.Marshal(frontmatter)
142 if err != nil {
143 return "", fmt.Errorf("failed to serialize frontmatter: %w", err)
144 }
145
146 buf.WriteString(delimiter + "\n")
147 buf.Write(yamlBytes)
148 buf.WriteString(delimiter + "\n")
149 if body != "" {
150 buf.WriteString(body)
151 if !strings.HasSuffix(body, "\n") {
152 buf.WriteString("\n")
153 }
154 }
155
156 return buf.String(), nil
157}

Callers 4

stripGitHubMetadataFunction · 0.92
InjectGitHubMetadataFunction · 0.85
InjectLocalMetadataFunction · 0.85
TestSerializeFunction · 0.85

Calls 3

ErrorfMethod · 0.65
WriteMethod · 0.65
StringMethod · 0.65

Tested by 1

TestSerializeFunction · 0.68