From 93050447887fda44dfa7cabe78a25ca1f9b3a3ea Mon Sep 17 00:00:00 2001 From: Tamer Tas <contact@tmrts.com> Date: Thu, 12 Jan 2017 19:41:16 +0300 Subject: [PATCH] pkg/prompt: deduplicate error branches --- pkg/prompt/prompt.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pkg/prompt/prompt.go b/pkg/prompt/prompt.go index ca1d1f0..0e1058e 100644 --- a/pkg/prompt/prompt.go +++ b/pkg/prompt/prompt.go @@ -74,14 +74,7 @@ func (p multipleChoicePrompt) PromptMessage(name string) string { func (p multipleChoicePrompt) EvaluateChoice(c string) (interface{}, error) { if c != "" { index, err := strconv.Atoi(c) - if err != nil { - tlog.Warn(fmt.Sprintf("Unrecognized choice %v, using the default choice", index)) - - return p[0], nil - } - - fmt.Println(len(p)) - if index > len(p) || index < 1 { + if err != nil || index < 1 || index > len(p) { tlog.Warn(fmt.Sprintf("Unrecognized choice %v, using the default choice", index)) return p[0], nil -- GitLab