MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / selectDestination

Function selectDestination

cli/cmd/init.go:239–263  ·  view source on GitHub ↗
(allPlugins []cqapi.ListPlugin, acceptDefaults bool)

Source from the content-addressed store, hash-verified

237}
238
239func selectDestination(allPlugins []cqapi.ListPlugin, acceptDefaults bool) (string, error) {
240 officialDestinations := lo.Filter(allPlugins, officialReleasedPluginsByKind(cqapi.PluginKindDestination))
241 slices.SortStableFunc(officialDestinations, pluginsSorter(destinationsOrder))
242 if acceptDefaults {
243 return officialDestinations[0].Name, nil
244 }
245
246 prompt := promptui.Select{
247 Label: "Select Destination Plugin",
248 Items: lo.Map(officialDestinations, pluginName),
249 Stdin: os.Stdin,
250 Size: 10,
251 StartInSearchMode: true,
252 Searcher: func(input string, index int) bool {
253 return strings.Contains(officialDestinations[index].Name, input)
254 },
255 }
256
257 _, destination, err := prompt.Run()
258 if err != nil {
259 return "", fmt.Errorf("destination prompt failed %w", err)
260 }
261
262 return destination, nil
263}
264
265func linkForPlugin(plugin cqapi.ListPlugin) string {
266 return link.Sprintf("https://www.cloudquery.io/hub/plugins/%s/%s/%s", plugin.Kind, plugin.TeamName, plugin.Name)

Callers 1

initCmdFunction · 0.85

Calls 4

pluginsSorterFunction · 0.85
RunMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected