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

Function Select

pkg/question/selectors/selectors.go:42–53  ·  view source on GitHub ↗
(ask question.Asker, questionText string, itemsCallback func() ([]T, error), getKey func(item T) string)

Source from the content-addressed store, hash-verified

40}
41
42func Select[T any](ask question.Asker, questionText string, itemsCallback func() ([]T, error), getKey func(item T) string) (T, error) {
43 items, err := itemsCallback()
44 if err != nil {
45 var item T
46 return item, err
47 }
48 if len(items) == 1 {
49 return items[0], nil
50 }
51
52 return question.SelectMap(ask, questionText, items, getKey)
53}
54
55// SelectOrNew is the same as Select but show a create new option at the bottom of the list
56// When create new is selected the returned bool will be true

Callers 15

PromptForProxyFunction · 0.92
PromptForMachinePolicyFunction · 0.92
PromptForSshAccountFunction · 0.92
PromptMissingFunction · 0.92
PromptMissingFunction · 0.92
PromptMissingFunction · 0.92
PromptMissingFunction · 0.92
promptForVariableFunction · 0.92
AskProjectsFunction · 0.92
getDbRunbookFunction · 0.92
getGitReferenceFunction · 0.92

Calls 1

SelectMapFunction · 0.92

Tested by 2

TestSelectForSingleItemFunction · 0.56