aboutsummaryrefslogtreecommitdiff
path: root/mal
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-07-03 22:57:06 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-07-03 22:57:06 +0530
commitbd0da056a9f4c1246ad5a980b1c824b7382478cf (patch)
tree3aedc5be2f841f8492b176cc77dcc95087caeede /mal
parent8494b2933908d54d0c64ca08d877efe4e3d8d7b3 (diff)
dynamically handling prompt length, search length, offset, etc
Diffstat (limited to 'mal')
-rw-r--r--mal/mal.go14
-rw-r--r--mal/search.go8
2 files changed, 11 insertions, 11 deletions
diff --git a/mal/mal.go b/mal/mal.go
index 9c55bcf..2bc1672 100644
--- a/mal/mal.go
+++ b/mal/mal.go
@@ -27,11 +27,15 @@ import (
um "github.com/MikunoNaka/MAL2Go/v2/user/manga"
)
-var animeClient a.Client
-var mangaClient m.Client
-var userClient u.Client
-var userAnimeClient ua.Client
-var userMangaClient um.Client
+var (
+ animeClient a.Client
+ mangaClient m.Client
+ userClient u.Client
+ userAnimeClient ua.Client
+ userMangaClient um.Client
+
+ SearchLength, SearchOffset int
+)
// init() would kill the program prematurely on `macli login` command
func Init() {
diff --git a/mal/search.go b/mal/search.go
index 8fee461..5add67f 100644
--- a/mal/search.go
+++ b/mal/search.go
@@ -26,11 +26,9 @@ import (
)
func SearchAnime(searchString string) []a.Anime {
- // TODO: read limit, offset from flags
- limit, offset := 10, 0
fields := []string{"title", "id", "my_list_status"}
- res, err := animeClient.SearchAnime(searchString, limit, offset, fields)
+ res, err := animeClient.SearchAnime(searchString, SearchLength, SearchOffset, fields)
if err != nil {
fmt.Println("MyAnimeList reported error while searching:", err.Error())
os.Exit(1)
@@ -40,11 +38,9 @@ func SearchAnime(searchString string) []a.Anime {
}
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)
+ res, err := mangaClient.SearchManga(searchString, SearchLength, SearchOffset, fields)
if err != nil {
fmt.Println("MyAnimeList reported error while searching:", err.Error())
os.Exit(1)