From e61698cc5b428ff80a1fe3e2da18c047df47b1d3 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Thu, 30 Jun 2022 18:36:25 +0530 Subject: added chapters command --- mal/episodes.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'mal') diff --git a/mal/episodes.go b/mal/episodes.go index c0ac116..06bb7a0 100644 --- a/mal/episodes.go +++ b/mal/episodes.go @@ -50,18 +50,20 @@ func SetEpisodes(animeId, prevValue int, ep string) a.UpdateResponse { return res } - func SetChapters(mangaId, prevValue int, ch string) m.UpdateResponse { - chValue, err := strconv.Atoi(ch) + chInt, err := strconv.Atoi(ch) if err != nil { fmt.Println("Error while parsing chapter input", err) os.Exit(1) } - sign := ch[0:1] - if sign == "+" || sign == "-" { - fmt.Printf("Cannot increment/decrement read chapters by %d\n. Currently that doesn't wokr", chValue) - os.Exit(2) + var chValue int + switch ch[0:1] { + case "+", "-": + // works both for increment and decrement + chValue = prevValue + chInt + default: + chValue = chInt } res, err := userMangaClient.SetChaptersRead(mangaId, chValue) -- cgit v1.2.3