Commit 132cc54772

132cc5477278c3d68fbd510d3a4d10c468985afd

parent: 0a4302b649

Unsigned

Wraient <wraient.911@gmail.com> · 2024-10-22 11:35 UTC

Add: ExitCurd()

Layout: unified · split

internal/curd.go +9 −4
@@ -79,6 +79,11 @@ func RestoreScreen() {
7979 fmt.Print("\033[?1049l") // Switch back to the main screen buffer
8080}
8181
82func ExitCurd() {
83 RestoreScreen()
84 os.Exit(0)
85}
86
8287func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAnimes *[]Anime, logFile string) {
8388 var err error
8489
@@ -91,10 +96,10 @@ func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAni
9196 // Select anime to watch (Anilist)
9297 anilistSelectedOption, err := DynamicSelect(animeListMap)
9398 if anilistSelectedOption.Key == "-1" || anilistSelectedOption.Label == "quit" {
94 os.Exit(0)
99 ExitCurd()
95100 }
96101 if anilistSelectedOption.Label == "add_new" { // Todo: Add new anime
97 os.Exit(0)
102 ExitCurd()
98103 }
99104 userQuery := anilistSelectedOption.Label
100105 anime.AnilistId, err = strconv.Atoi(anilistSelectedOption.Key)
@@ -127,7 +132,7 @@ func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAni
127132 }
128133 if len(animeList) == 0 {
129134 fmt.Println("No results found.")
130 os.Exit(0)
135 ExitCurd()
131136 }
132137
133138 // find anime in animeList
@@ -139,7 +144,7 @@ func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAni
139144 selectedAllanimeAnime, err := DynamicSelect(animeList)
140145 if err != nil {
141146 fmt.Println("No anime available")
142 os.Exit(0)
147 ExitCurd()
143148 }
144149 anime.AllanimeId = selectedAllanimeAnime.Key
145150 }