MCPcopy
hub / github.com/crowdsecurity/crowdsec / compInstalledItems

Function compInstalledItems

cmd/crowdsec-cli/cliitem/item.go:112–131  ·  view source on GitHub ↗
(itemType string, _ []string, toComplete string, cfg csconfig.Getter)

Source from the content-addressed store, hash-verified

110}
111
112func compInstalledItems(itemType string, _ []string, toComplete string, cfg csconfig.Getter) ([]string, cobra.ShellCompDirective) {
113 hub, err := require.Hub(cfg(), nil)
114 if err != nil {
115 return nil, cobra.ShellCompDirectiveDefault
116 }
117
118 items := hub.GetInstalledByType(itemType, true)
119
120 comp := make([]string, 0)
121
122 for _, item := range items {
123 if strings.Contains(item.Name, toComplete) {
124 comp = append(comp, item.Name)
125 }
126 }
127
128 cobra.CompDebugln(fmt.Sprintf("%s: %+v", itemType, comp), true)
129
130 return comp, cobra.ShellCompDirectiveNoFileComp
131}

Callers 3

newInspectCmdMethod · 0.85
newUpgradeCmdMethod · 0.85
newRemoveCmdMethod · 0.85

Calls 2

HubFunction · 0.92
GetInstalledByTypeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…