diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-06-30 18:36:25 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-06-30 18:36:25 +0530 |
commit | e61698cc5b428ff80a1fe3e2da18c047df47b1d3 (patch) | |
tree | 9734d6d38706346420ed14617c10f676a834db3f /mal | |
parent | d3951be451e7df5d889061716c94602ba6b1d71a (diff) |
added chapters command
Diffstat (limited to 'mal')
-rw-r--r-- | mal/episodes.go | 14 |
1 files changed, 8 insertions, 6 deletions
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) |