From ab3db8a4ca89293ce0928177e8845d622f13755f Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Wed, 15 Jun 2022 12:59:22 +0530 Subject: added pretty template for TextInput --- mal/search.go | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'mal/search.go') diff --git a/mal/search.go b/mal/search.go index 2968611..703cdb4 100644 --- a/mal/search.go +++ b/mal/search.go @@ -19,24 +19,36 @@ along with this program. If not, see . package mal import ( - "log" + "fmt" + "os" a "github.com/MikunoNaka/MAL2Go/anime" + m "github.com/MikunoNaka/MAL2Go/manga" ) -func SearchAnime(searchString string, extraFields []string) []a.Anime { - // TODO: load limit, offset and (maybe) fields from config +func SearchAnime(searchString string) []a.Anime { + // TODO: read limit, offset from flags limit, offset := 10, 0 - - fields := []string{"title", "id"} - for _, i := range extraFields { - fields = append(fields, i) - } + fields := []string{"title", "id", "my_list_status"} res, err := animeClient.SearchAnime(searchString, limit, offset, fields) if err != nil { - log.Println(err) - return []a.Anime{} + fmt.Println("MyAnimeList reported error while searching:", err.Error()) + os.Exit(1) } return res.Animes } + +func SearchManga(searchString string) []m.Manga { + // TODO: read limit, offset from flags + limit, offset := 10, 0 + fields := []string{"title", "id", "my_list_status"} + + res, err := mangaClient.SearchManga(searchString, limit, offset, fields) + if err != nil { + fmt.Println("MyAnimeList reported error while searching:", err.Error()) + os.Exit(1) + } + + return res.Mangas +} -- cgit v1.2.3