From a3a7b41179d8abe9edc705db6b14063e95c459fa Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Thu, 30 Jun 2022 20:15:05 +0530 Subject: added --query option to episodes and chapters command --- ui/episodes.go | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'ui') diff --git a/ui/episodes.go b/ui/episodes.go index edf05a4..8b1bcff 100644 --- a/ui/episodes.go +++ b/ui/episodes.go @@ -39,10 +39,8 @@ func CreateChapterUpdateConfirmationMessage(title string, prevChNum, chNum int) } func EpisodeInput(anime a.Anime) { - // fetch number of total episodes, number of watched episodes from the API - animeData := mal.GetAnimeData(anime.Id, []string{"num_episodes", "my_list_status"}) - epWatchedNum := animeData.MyListStatus.EpWatched - epTotalNum := animeData.NumEpisodes + epWatchedNum := anime.MyListStatus.EpWatched + epTotalNum := anime.NumEpisodes validate := func(input string) error { if _, err := strconv.ParseFloat(input, 64); err != nil { @@ -74,10 +72,8 @@ func EpisodeInput(anime a.Anime) { } func ChapterInput(manga m.Manga) { - // fetch number of total chapters, number of read chapters from the API - animeData := mal.GetMangaData(manga.Id, []string{"num_chapters", "my_list_status"}) - chReadNum := animeData.MyListStatus.ChaptersRead - chTotalNum := animeData.NumChapters + chReadNum := manga.MyListStatus.ChaptersRead + chTotalNum := manga.NumChapters validate := func(input string) error { if _, err := strconv.ParseFloat(input, 64); err != nil { @@ -104,6 +100,6 @@ func ChapterInput(manga m.Manga) { os.Exit(1) } - // TODO: read resp and show confirmation message - mal.SetChapters(manga.Id, chReadNum, res) + resp := mal.SetChapters(manga.Id, chReadNum, res) + fmt.Println(CreateChapterUpdateConfirmationMessage(manga.Title, chReadNum, resp.ChaptersRead)) } -- cgit v1.2.3