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

Function extractInputs

pkg/cli/generate_action_metadata_command.go:216–253  ·  view source on GitHub ↗

extractInputs extracts input parameters from core.getInput() calls

(content string)

Source from the content-addressed store, hash-verified

214
215// extractInputs extracts input parameters from core.getInput() calls
216func extractInputs(content string) []ActionInput {
217 var inputs []ActionInput
218 seen := make(map[string]struct {
219 })
220
221 // Match core.getInput('name') or core.getInput("name")
222 matches := coreGetInputPattern.FindAllStringSubmatch(content, -1)
223
224 for _, match := range matches {
225 if len(match) > 1 {
226 inputName := match[1]
227 if !setutil.Contains(seen, inputName) {
228 inputs = append(inputs, ActionInput{
229 Name: inputName,
230 Description: "Input parameter: " + inputName,
231 Required: false,
232 Default: "",
233 })
234 seen[inputName] = struct {
235 }{}
236 }
237 }
238 }
239
240 // Sort inputs by name for consistency
241 slices.SortFunc(inputs, func(a, b ActionInput) int {
242 switch {
243 case a.Name < b.Name:
244 return -1
245 case a.Name > b.Name:
246 return 1
247 default:
248 return 0
249 }
250 })
251
252 return inputs
253}
254
255// extractOutputs extracts output parameters from core.setOutput() calls
256func extractOutputs(content string) []ActionOutput {

Callers 2

extractActionMetadataFunction · 0.85
TestExtractInputsFunction · 0.85

Calls 1

ContainsFunction · 0.92

Tested by 1

TestExtractInputsFunction · 0.68