MCPcopy
hub / github.com/cli/cli / IndexFor

Function IndexFor

internal/prompter/test.go:150–157  ·  view source on GitHub ↗
(options []string, answer string)

Source from the content-addressed store, hash-verified

148}
149
150func IndexFor(options []string, answer string) (int, error) {
151 for ix, a := range options {
152 if a == answer {
153 return ix, nil
154 }
155 }
156 return -1, NoSuchAnswerErr(answer, options)
157}
158
159func IndexesFor(options []string, answers ...string) ([]int, error) {
160 indexes := make([]int, len(answers))

Callers 15

Test_viewRunFunction · 0.92
TestSwitchRunFunction · 0.92
Test_refreshRunFunction · 0.92
TestLoginFunction · 0.92
Test_loginRun_SurveyFunction · 0.92
Test_logoutRun_ttyFunction · 0.92
TestRunViewWeb_TTYFunction · 0.92
Test_runLockFunction · 0.92
Test_createRunFunction · 0.92
TestIssueCreate_recoverFunction · 0.92

Calls 1

NoSuchAnswerErrFunction · 0.85

Tested by 15

Test_viewRunFunction · 0.74
TestSwitchRunFunction · 0.74
Test_refreshRunFunction · 0.74
TestLoginFunction · 0.74
Test_loginRun_SurveyFunction · 0.74
Test_logoutRun_ttyFunction · 0.74
TestRunViewWeb_TTYFunction · 0.74
Test_runLockFunction · 0.74
Test_createRunFunction · 0.74
TestIssueCreate_recoverFunction · 0.74