Skip to content

Commit

Permalink
fix max num of results
Browse files Browse the repository at this point in the history
  • Loading branch information
laureanray committed Aug 16, 2023
1 parent c2e39f3 commit 3203278
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion cmd/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func getExtension(s string) string {
var (
selectedFilter string
outputDirectory string
numberOfResults = 10
numberOfResults int

searchCmd = &cobra.Command{
Use: "search",
Expand All @@ -44,6 +44,9 @@ var (

m := mirror.NewLegacyMirror(libgen.IS)

// Set Defaults
m.SetNumberOfResults(numberOfResults)

var books []book.Book

switch selectedFilter {
Expand Down Expand Up @@ -71,6 +74,7 @@ var (
prompt := promptui.Select{
Label: "Select Title",
Items: titles,
Size: 10,
}

resultInt, _, err := prompt.Run()
Expand Down
6 changes: 5 additions & 1 deletion internal/mirror/legacy_mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions internal/mirror/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ type Configuration struct {
type NewMirror struct {
domain libgen.Domain
}


0 comments on commit 3203278

Please sign in to comment.