From af8701225a83e0521b6f5e5c68aab6b4f0809749 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Thu, 30 Jun 2022 00:17:26 +0530 Subject: added confirmation message and color coding when setting anime status --- ui/status.go | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/status.go b/ui/status.go index 09fd3d0..2b3894a 100644 --- a/ui/status.go +++ b/ui/status.go @@ -33,6 +33,24 @@ type StatusOption struct { Status string } +// to print dropped in red color, etc +func getColorCodeByStatus(status string) string { + switch status { + case "watching", "reading": + return "\x1b[32m" + case "completed": + return "\x1b[34m" + case "on_hold": + return "\x1b[33m" + case "dropped": + return "\x1b[31m" + case "plan_to_watch", "plan_to_read": + return "\x1b[36m" + default: + return "" + } +} + func AnimeStatusMenu(anime a.Anime) { options := []StatusOption { {"Watching", "watching"}, @@ -85,7 +103,8 @@ func AnimeStatusMenu(anime a.Anime) { os.Exit(1) } - mal.SetAnimeStatus(anime.Id, options[res].Status) + resp := mal.SetAnimeStatus(anime.Id, options[res].Status) + fmt.Println("Set \x1b[35m" + anime.Title + "\x1b[0m status to " + getColorCodeByStatus(resp.Status) + resp.Status + "\x1b[0m") } func MangaStatusMenu(manga m.Manga) { @@ -140,5 +159,6 @@ func MangaStatusMenu(manga m.Manga) { os.Exit(1) } - mal.SetMangaStatus(manga.Id, options[res].Status) + resp := mal.SetMangaStatus(manga.Id, options[res].Status) + fmt.Println("Set \x1b[35m" + manga.Title + "\x1b[0m status to " + getColorCodeByStatus(resp.Status) + resp.Status + "\x1b[0m") } -- cgit v1.2.3