Don't suggest an item which user already mentioned. (#1702)

This commit is contained in:
Shivam Sandbhor 2022-09-28 16:56:47 +05:30 committed by GitHub
parent 568eb1d4e0
commit 52447f6999
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -112,12 +112,8 @@ func compAllItems(itemType string, args []string, toComplete string) ([]string,
comp := make([]string, 0)
hubItems := cwhub.GetHubStatusForItemType(itemType, "", true)
for _, item := range hubItems {
if toComplete == "" {
if !inSlice(item.Name, args) && strings.Contains(item.Name, toComplete) {
comp = append(comp, item.Name)
} else {
if strings.Contains(item.Name, toComplete) {
comp = append(comp, item.Name)
}
}
}
cobra.CompDebugln(fmt.Sprintf("%s: %+v", itemType, comp), true)