MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / PromptScope

Function PromptScope

pkg/cmd/project/variables/shared/input.go:56–74  ·  view source on GitHub ↗
(ask question.Asker, scopeDescription string, items []*resources.ReferenceDataItem, displaySelector func(i *resources.ReferenceDataItem) string)

Source from the content-addressed store, hash-verified

54}
55
56func PromptScope(ask question.Asker, scopeDescription string, items []*resources.ReferenceDataItem, displaySelector func(i *resources.ReferenceDataItem) string) ([]string, error) {
57 if displaySelector == nil {
58 displaySelector = func(i *resources.ReferenceDataItem) string { return i.Name }
59 }
60 if util.Empty(items) {
61 return nil, nil
62 }
63 var selectedItems []string
64 err := ask(&survey.MultiSelect{
65 Message: fmt.Sprintf("%s scope", scopeDescription),
66 Options: util.SliceTransform(items, displaySelector),
67 }, &selectedItems)
68
69 if err != nil {
70 return nil, err
71 }
72
73 return selectedItems, nil
74}

Callers 3

TestPromptScope_NoItemsFunction · 0.92
TestPromptScope_HasItemsFunction · 0.92
PromptScopesFunction · 0.85

Calls 2

EmptyFunction · 0.92
SliceTransformFunction · 0.92

Tested by 2

TestPromptScope_NoItemsFunction · 0.74
TestPromptScope_HasItemsFunction · 0.74