From 6e10ab2b0bea332dc836f04e76d6c58b487b894a Mon Sep 17 00:00:00 2001 From: laureanray Date: Sun, 26 Jun 2022 20:13:03 +0800 Subject: [PATCH] fix: bug where selection is always 0 index --- cmd/search.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/search.go b/cmd/search.go index 8954e04..62125b4 100644 --- a/cmd/search.go +++ b/cmd/search.go @@ -6,7 +6,6 @@ import ( "github.com/manifoldco/promptui" "github.com/spf13/cobra" "log" - "strconv" ) var ( @@ -55,7 +54,8 @@ var ( Label: "Select Title", Items: titles, } - _, result, err := prompt.Run() + + resultInt, result, err := prompt.Run() if err != nil { fmt.Printf("Prompt failed %v\n", err) @@ -64,9 +64,9 @@ var ( log.Printf("You choose [%s]", result) - selection, _ := strconv.Atoi(result) + log.Println("Selection: ", resultInt, books[resultInt]) - api.DownloadSelection(books[selection], libgenType) + api.DownloadSelection(books[resultInt], libgenType) }, } )