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

Function CompleteEventTypes

pkg/cmd/event/shared/completion.go:20–35  ·  view source on GitHub ↗

CompleteEventTypes returns the known event types that complete the last comma-separated item of toComplete, each prefixed with the preceding items and followed by its description. Types already listed are left out.

(toComplete string)

Source from the content-addressed store, hash-verified

18// CompleteEventTypes returns the known event types that complete the last comma-separated item of toComplete, each
19// prefixed with the preceding items and followed by its description. Types already listed are left out.
20func CompleteEventTypes(toComplete string) []string {
21 var prefix string
22 var chosen []string
23 if idx := strings.LastIndexByte(toComplete, ','); idx >= 0 {
24 prefix = toComplete[:idx+1]
25 chosen = strings.Split(toComplete[:idx], ",")
26 toComplete = toComplete[idx+1:]
27 }
28 var results []string
29 for _, t := range EventTypes {
30 if strings.HasPrefix(t.Name, toComplete) && !slices.Contains(chosen, t.Name) {
31 results = append(results, prefix+t.Name+"\t"+t.Description)
32 }
33 }
34 return results
35}

Callers 2

TestCompleteEventTypesFunction · 0.85

Calls 1

ContainsMethod · 0.80

Tested by 1

TestCompleteEventTypesFunction · 0.68