diff options
author | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-06-30 00:17:26 +0530 |
---|---|---|
committer | Vidhu Kant Sharma <vidhukant@vidhukant.xyz> | 2022-06-30 00:17:26 +0530 |
commit | af8701225a83e0521b6f5e5c68aab6b4f0809749 (patch) | |
tree | 09bd33351c8dc4e73252c806f6efb7900cb4c07a /ui | |
parent | 787860249267d96f6100415183afc07959dc9048 (diff) |
added confirmation message and color coding when setting anime status
Diffstat (limited to 'ui')
-rw-r--r-- | ui/status.go | 24 |
1 files changed, 22 insertions, 2 deletions
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") } |