MCPcopy Create free account
hub / github.com/github/gh-aw / extractOutputs

Function extractOutputs

pkg/cli/generate_action_metadata_command.go:256–291  ·  view source on GitHub ↗

extractOutputs extracts output parameters from core.setOutput() calls

(content string)

Source from the content-addressed store, hash-verified

254
255// extractOutputs extracts output parameters from core.setOutput() calls
256func extractOutputs(content string) []ActionOutput {
257 var outputs []ActionOutput
258 seen := make(map[string]struct {
259 })
260
261 // Match core.setOutput('name', ...) or core.setOutput("name", ...)
262 matches := coreSetOutputPattern.FindAllStringSubmatch(content, -1)
263
264 for _, match := range matches {
265 if len(match) > 1 {
266 outputName := match[1]
267 if !setutil.Contains(seen, outputName) {
268 outputs = append(outputs, ActionOutput{
269 Name: outputName,
270 Description: "Output parameter: " + outputName,
271 })
272 seen[outputName] = struct {
273 }{}
274 }
275 }
276 }
277
278 // Sort outputs by name for consistency
279 slices.SortFunc(outputs, func(a, b ActionOutput) int {
280 switch {
281 case a.Name < b.Name:
282 return -1
283 case a.Name > b.Name:
284 return 1
285 default:
286 return 0
287 }
288 })
289
290 return outputs
291}
292
293// extractDependencies extracts require() dependencies
294func extractDependencies(content string) []string {

Callers 2

extractActionMetadataFunction · 0.85
TestExtractOutputsFunction · 0.85

Calls 1

ContainsFunction · 0.92

Tested by 1

TestExtractOutputsFunction · 0.68