MCPcopy Index your code
hub / github.com/crowdsecurity/crowdsec / compAllItems

Function compAllItems

cmd/crowdsec-cli/cliitem/cmdinstall.go:108–125  ·  view source on GitHub ↗
(itemType string, args []string, toComplete string, cfg csconfig.Getter)

Source from the content-addressed store, hash-verified

106}
107
108func compAllItems(itemType string, args []string, toComplete string, cfg csconfig.Getter) ([]string, cobra.ShellCompDirective) {
109 hub, err := require.Hub(cfg(), nil)
110 if err != nil {
111 return nil, cobra.ShellCompDirectiveDefault
112 }
113
114 comp := make([]string, 0)
115
116 for _, item := range hub.GetItemsByType(itemType, false) {
117 if !slices.Contains(args, item.Name) && strings.Contains(item.Name, toComplete) {
118 comp = append(comp, item.Name)
119 }
120 }
121
122 cobra.CompDebugln(fmt.Sprintf("%s: %+v", itemType, comp), true)
123
124 return comp, cobra.ShellCompDirectiveNoFileComp
125}
126
127func (cli *cliItem) newInstallCmd() *cobra.Command {
128 var (

Callers 1

newInstallCmdMethod · 0.85

Calls 2

HubFunction · 0.92
GetItemsByTypeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…