Commit 132cc54772
Unsigned
Layout: unified · split
internal/curd.go +9 −4
| @@ -79,6 +79,11 @@ func RestoreScreen() { | ||
| 79 | 79 | fmt.Print("\033[?1049l") // Switch back to the main screen buffer |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | func ExitCurd() { | |
| 83 | RestoreScreen() | |
| 84 | os.Exit(0) | |
| 85 | } | |
| 86 | ||
| 82 | 87 | func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAnimes *[]Anime, logFile string) { |
| 83 | 88 | var err error |
| 84 | 89 | |
| @@ -91,10 +96,10 @@ func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAni | ||
| 91 | 96 | // Select anime to watch (Anilist) |
| 92 | 97 | anilistSelectedOption, err := DynamicSelect(animeListMap) |
| 93 | 98 | if anilistSelectedOption.Key == "-1" || anilistSelectedOption.Label == "quit" { |
| 94 | os.Exit(0) | |
| 99 | ExitCurd() | |
| 95 | 100 | } |
| 96 | 101 | if anilistSelectedOption.Label == "add_new" { // Todo: Add new anime |
| 97 | os.Exit(0) | |
| 102 | ExitCurd() | |
| 98 | 103 | } |
| 99 | 104 | userQuery := anilistSelectedOption.Label |
| 100 | 105 | anime.AnilistId, err = strconv.Atoi(anilistSelectedOption.Key) |
| @@ -127,7 +132,7 @@ func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAni | ||
| 127 | 132 | } |
| 128 | 133 | if len(animeList) == 0 { |
| 129 | 134 | fmt.Println("No results found.") |
| 130 | os.Exit(0) | |
| 135 | ExitCurd() | |
| 131 | 136 | } |
| 132 | 137 | |
| 133 | 138 | // find anime in animeList |
| @@ -139,7 +144,7 @@ func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAni | ||
| 139 | 144 | selectedAllanimeAnime, err := DynamicSelect(animeList) |
| 140 | 145 | if err != nil { |
| 141 | 146 | fmt.Println("No anime available") |
| 142 | os.Exit(0) | |
| 147 | ExitCurd() | |
| 143 | 148 | } |
| 144 | 149 | anime.AllanimeId = selectedAllanimeAnime.Key |
| 145 | 150 | } |