From 2bb89f25599f48c4953801298c4f9ef8dee12246 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Mon, 4 Jul 2022 21:27:02 +0530 Subject: added --id flag to search and score command --- ui/score.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'ui/score.go') 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)) } -- cgit v1.2.3