From 3203278fa677c781b30cab123ee1e861a94bbeca Mon Sep 17 00:00:00 2001 From: laureanray Date: Thu, 17 Aug 2023 03:40:20 +0800 Subject: [PATCH] fix max num of results --- cmd/search.go | 6 +++++- internal/mirror/legacy_mirror.go | 6 +++++- internal/mirror/mirror.go | 2 -- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/search.go b/cmd/search.go index 987317d..ede22fa 100644 --- a/cmd/search.go +++ b/cmd/search.go @@ -29,7 +29,7 @@ func getExtension(s string) string { var ( selectedFilter string outputDirectory string - numberOfResults = 10 + numberOfResults int searchCmd = &cobra.Command{ Use: "search", @@ -44,6 +44,9 @@ var ( m := mirror.NewLegacyMirror(libgen.IS) + // Set Defaults + m.SetNumberOfResults(numberOfResults) + var books []book.Book switch selectedFilter { @@ -71,6 +74,7 @@ var ( prompt := promptui.Select{ Label: "Select Title", Items: titles, + Size: 10, } resultInt, _, err := prompt.Run() diff --git a/internal/mirror/legacy_mirror.go b/internal/mirror/legacy_mirror.go index 40410a0..a0f25d2 100644 --- a/internal/mirror/legacy_mirror.go +++ b/internal/mirror/legacy_mirror.go @@ -25,11 +25,15 @@ func NewLegacyMirror(domain libgen.Domain) *LegacyMirror { domain: domain, // TODO: Make this configurable config: Configuration{ - numberOfResults: 5, + numberOfResults: 10, }, } } +func (m *LegacyMirror) SetNumberOfResults(numberOfResults int) { + m.config.numberOfResults = numberOfResults +} + func (m *LegacyMirror) SearchByTitle(query string) ([]book.Book, error) { fmt.Println("Searching for: ", console.Higlight(query)) var document *goquery.Document diff --git a/internal/mirror/mirror.go b/internal/mirror/mirror.go index 16facdd..941c93b 100644 --- a/internal/mirror/mirror.go +++ b/internal/mirror/mirror.go @@ -20,5 +20,3 @@ type Configuration struct { type NewMirror struct { domain libgen.Domain } - -