CrawlerIDs returns a function to list the crawler IDs from the given crawler client.
( clientF func() (*crawler.Client, error), )
| 32 | |
| 33 | // CrawlerIDs returns a function to list the crawler IDs from the given crawler client. |
| 34 | func CrawlerIDs( |
| 35 | clientF func() (*crawler.Client, error), |
| 36 | ) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 37 | return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 38 | client, err := clientF() |
| 39 | if err != nil { |
| 40 | return nil, cobra.ShellCompDirectiveError |
| 41 | } |
| 42 | items, err := client.ListAll("", "") |
| 43 | if err != nil { |
| 44 | return nil, cobra.ShellCompDirectiveError |
| 45 | } |
| 46 | |
| 47 | names := make([]string, 0, len(items)) |
| 48 | for _, crawler := range items { |
| 49 | names = append(names, fmt.Sprintf("%s\t%s", crawler.ID, crawler.Name)) |
| 50 | } |
| 51 | return names, cobra.ShellCompDirectiveNoFileComp |
| 52 | } |
| 53 | } |
no test coverage detected