aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-06-30 00:22:46 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-06-30 00:22:46 +0530
commit5ad76ed2e6e67b421c27ff153e2ae348152eaa40 (patch)
tree419ff383e201e3427f0b2f300089d8da74142ae1
parentaf8701225a83e0521b6f5e5c68aab6b4f0809749 (diff)
added confirmation message and color coding when setting anime status
-rw-r--r--cmd/status.go8
-rw-r--r--ui/status.go9
2 files changed, 11 insertions, 6 deletions
diff --git a/cmd/status.go b/cmd/status.go
index feb5c10..dcf177c 100644
--- a/cmd/status.go
+++ b/cmd/status.go
@@ -68,8 +68,8 @@ func setAnimeStatus(statusInput, searchInput string) {
if statusInput == "" {
ui.AnimeStatusMenu(anime)
} else {
- mal.SetAnimeStatus(anime.Id, statusInput)
- fmt.Printf("Successfully set \"%s\" to \"%s\"\n", anime.Title, statusInput)
+ resp := mal.SetAnimeStatus(anime.Id, statusInput)
+ fmt.Println(ui.CreateStatusUpdateConfirmationMessage(anime.Title, resp.Status))
}
}
@@ -83,8 +83,8 @@ func setMangaStatus(statusInput, searchInput string) {
if statusInput == "" {
ui.MangaStatusMenu(manga)
} else {
- mal.SetAnimeStatus(manga.Id, statusInput)
- fmt.Printf("Successfully set \"%s\" to \"%s\"\n", manga.Title, statusInput)
+ resp := mal.SetAnimeStatus(manga.Id, statusInput)
+ fmt.Println(ui.CreateStatusUpdateConfirmationMessage(manga.Title, resp.Status))
}
}
diff --git a/ui/status.go b/ui/status.go
index 2b3894a..d1a40c3 100644
--- a/ui/status.go
+++ b/ui/status.go
@@ -51,6 +51,11 @@ func getColorCodeByStatus(status string) string {
}
}
+// very short name I know
+func CreateStatusUpdateConfirmationMessage(title, status string) string {
+ return "Set \x1b[35m" + title + "\x1b[0m status to " + getColorCodeByStatus(status) + status + "\x1b[0m"
+}
+
func AnimeStatusMenu(anime a.Anime) {
options := []StatusOption {
{"Watching", "watching"},
@@ -104,7 +109,7 @@ func AnimeStatusMenu(anime a.Anime) {
}
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")
+ fmt.Println(CreateStatusUpdateConfirmationMessage(anime.Title, resp.Status))
}
func MangaStatusMenu(manga m.Manga) {
@@ -160,5 +165,5 @@ func MangaStatusMenu(manga m.Manga) {
}
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")
+ fmt.Println(CreateStatusUpdateConfirmationMessage(manga.Title, resp.Status))
}