diff options
| -rw-r--r-- | cmd/status.go | 51 | ||||
| -rw-r--r-- | mal/search.go | 2 | ||||
| -rw-r--r-- | ui/status.go | 29 | 
3 files changed, 67 insertions, 15 deletions
diff --git a/cmd/status.go b/cmd/status.go index bd4307e..d79d5a6 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -63,32 +63,59 @@ var statusCmd = &cobra.Command{  func setAnimeStatus(statusInput, searchInput string) {  	if searchInput == "" { -		searchInput = ui.TextInput("Search Anime To Update: ", "Search can't be blank.") +	    var promptText string +		if queryOnlyMode { +			promptText = "Search Anime to Get Status of: " +		} else { +			promptText = "Search Anime to Set Status of: " +		} +	   	searchInput = ui.TextInput(promptText, "Search can't be blank.")  	}  	anime := ui.AnimeSearch("Select Anime:", searchInput) -	if statusInput == "" { -		ui.AnimeStatusMenu(anime) -	} else { -		resp := mal.SetAnimeStatus(anime.Id, statusInput) -		fmt.Println(ui.CreateStatusUpdateConfirmationMessage(anime.Title, resp.Status)) +	if queryOnlyMode { +		status := anime.MyListStatus.Status +		// fmt.Printf("Anime: \x1b[35m%s\x1b[0m, Status: %s%s\x1b[0m\n", anime.Title, ui.GetColorCodeByStatus(status), ui.FormatStatus(status)) +		fmt.Printf("\x1b[35m%s\x1b[0m :: %s%s\x1b[0m\n", anime.Title, ui.GetColorCodeByStatus(status), ui.FormatStatus(status)) +		os.Exit(0)  	} + +    if statusInput == "" { +    	ui.AnimeStatusMenu(anime) +    } else { +    	resp := mal.SetAnimeStatus(anime.Id, statusInput) +    	fmt.Println(ui.CreateStatusUpdateConfirmationMessage(anime.Title, resp.Status)) +    }  }  func setMangaStatus(statusInput, searchInput string) {  	if searchInput == "" { -		searchInput = ui.TextInput("Search Manga To Update: ", "Search can't be blank.") +	    var promptText string +		if queryOnlyMode { +			promptText = "Search Manga to Get Status of: " +		} else { +			promptText = "Search Manga to Set Status of: " +		} +	   	searchInput = ui.TextInput(promptText, "Search can't be blank.")  	}  	manga := ui.MangaSearch("Select Manga:", searchInput) -	if statusInput == "" { -		ui.MangaStatusMenu(manga) -	} else { -		resp := mal.SetAnimeStatus(manga.Id, statusInput) -		fmt.Println(ui.CreateStatusUpdateConfirmationMessage(manga.Title, resp.Status)) +	if queryOnlyMode { +		status := manga.MyListStatus.Status +		// fmt.Printf("Manga: \x1b[35m%s\x1b[0m, Status: %s%s\x1b[0m\n", manga.Title, ui.GetColorCodeByStatus(status), ui.FormatStatus(status)) +		fmt.Printf("\x1b[35m%s\x1b[0m :: %s%s\x1b[0m\n", manga.Title, ui.GetColorCodeByStatus(status), ui.FormatStatus(status)) +		os.Exit(0)  	} + +    if statusInput == "" { +    	ui.MangaStatusMenu(manga) +    } else { +    	resp := mal.SetMangaStatus(manga.Id, statusInput) +		fmt.Println(resp.Status) +    	fmt.Println(ui.CreateStatusUpdateConfirmationMessage(manga.Title, resp.Status)) +    }  }  func init() { diff --git a/mal/search.go b/mal/search.go index de2c53c..8fee461 100644 --- a/mal/search.go +++ b/mal/search.go @@ -28,7 +28,7 @@ import (  func SearchAnime(searchString string) []a.Anime {    // TODO: read limit, offset from flags    limit, offset := 10, 0 -  fields := []string{"title", "id", "my_list_status", "num_episodes"} +  fields := []string{"title", "id", "my_list_status"}    res, err := animeClient.SearchAnime(searchString, limit, offset, fields)    if err != nil { diff --git a/ui/status.go b/ui/status.go index d1a40c3..7e8687e 100644 --- a/ui/status.go +++ b/ui/status.go @@ -34,7 +34,7 @@ type StatusOption struct {  }  // to print dropped in red color, etc -func getColorCodeByStatus(status string) string { +func GetColorCodeByStatus(status string) string {    switch status {      case "watching", "reading":        return "\x1b[32m" @@ -46,6 +46,31 @@ func getColorCodeByStatus(status string) string {        return "\x1b[31m"      case "plan_to_watch", "plan_to_read":        return "\x1b[36m" +    case "": +      return "\x1b[38;5;7m" +    default: +      return "" +  } +} + +func FormatStatus(status string) string { +  switch status { +    case "watching": +      return "Watching" +    case "reading": +      return "Reading" +    case "completed": +      return "Completed" +    case "on_hold": +      return "On Hold" +    case "dropped": +      return "Dropped" +    case "plan_to_watch": +      return "Plan to Watch" +    case "plan_to_read": +      return "Plan to Read" +    case "": +      return "Not in List"      default:        return ""    } @@ -53,7 +78,7 @@ 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" +  return "Set \x1b[35m" + title + "\x1b[0m status to " + GetColorCodeByStatus(status) + FormatStatus(status) + "\x1b[0m"  }  func AnimeStatusMenu(anime a.Anime) {  |