aboutsummaryrefslogtreecommitdiff
path: root/ui/score.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-07-04 21:27:02 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-07-04 21:27:02 +0530
commit2bb89f25599f48c4953801298c4f9ef8dee12246 (patch)
treecabb4414f8cda3104d0003cdf69d73b0ecbc7e32 /ui/score.go
parenta8c3e33462bc295bd727e39364cfd26e4aa4ea4d (diff)
added --id flag to search and score command
Diffstat (limited to 'ui/score.go')
-rw-r--r--ui/score.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/ui/score.go b/ui/score.go
index 2b8a549..d035cee 100644
--- a/ui/score.go
+++ b/ui/score.go
@@ -65,8 +65,11 @@ func FormatScore(score int) string {
}
// very short name I know
-func CreateScoreUpdateConfirmationMessage(title string, prevScore, score int) string {
- return fmt.Sprintf("\x1b[35m%s\x1b[0m Score :: %s -> %s", title, FormatScore(prevScore), FormatScore(score))
+func CreateScoreUpdateConfirmationMessage(title string, score, prevScore int) string {
+ if prevScore >= 0 {
+ return fmt.Sprintf("\x1b[35m%s\x1b[0m Score :: %s -> %s", title, FormatScore(prevScore), FormatScore(score))
+ }
+ return fmt.Sprintf("\x1b[35m%s\x1b[0m Score :: %s", title, FormatScore(score))
}
func AnimeScoreInput(anime a.Anime) {
@@ -105,7 +108,7 @@ func AnimeScoreInput(anime a.Anime) {
}
resp := mal.SetAnimeScore(anime.Id, util.ParseNumeric(res, currentScore))
- fmt.Println(CreateScoreUpdateConfirmationMessage(anime.Title, currentScore, resp.Score))
+ fmt.Println(CreateScoreUpdateConfirmationMessage(anime.Title, resp.Score ,currentScore))
}
func MangaScoreInput(manga m.Manga) {
@@ -145,5 +148,5 @@ func MangaScoreInput(manga m.Manga) {
}
resp := mal.SetMangaScore(manga.Id, util.ParseNumeric(res, currentScore))
- fmt.Println(CreateScoreUpdateConfirmationMessage(manga.Title, currentScore, resp.Score))
+ fmt.Println(CreateScoreUpdateConfirmationMessage(manga.Title, resp.Score ,currentScore))
}