Commit 16834a0625
Unsigned
Layout: unified · split
VERSION.txt +1 −1
| @@ -1 +1 @@ | ||
| 1 | 0.0.3 | |
| \ No newline at end of file | ||
| 1 | 0.0.4 | |
| \ No newline at end of file | ||
cmd/curd/main.go +48 −42
| @@ -23,14 +23,14 @@ func main() { | ||
| 23 | 23 | var anime internal.Anime |
| 24 | 24 | var user internal.User |
| 25 | 25 | |
| 26 | var homeDir string | |
| 27 | if runtime.GOOS == "windows" { | |
| 28 | homeDir = os.Getenv("USERPROFILE") | |
| 29 | } else { | |
| 30 | homeDir = os.Getenv("HOME") | |
| 31 | } | |
| 26 | var homeDir string | |
| 27 | if runtime.GOOS == "windows" { | |
| 28 | homeDir = os.Getenv("USERPROFILE") | |
| 29 | } else { | |
| 30 | homeDir = os.Getenv("HOME") | |
| 31 | } | |
| 32 | 32 | |
| 33 | configFilePath := filepath.Join(homeDir, ".config", "curd", "curd.conf") | |
| 33 | configFilePath := filepath.Join(homeDir, ".config", "curd", "curd.conf") | |
| 34 | 34 | |
| 35 | 35 | // load curd userCurdConfig |
| 36 | 36 | userCurdConfig, err := internal.LoadConfig(configFilePath) |
| @@ -38,6 +38,7 @@ func main() { | ||
| 38 | 38 | fmt.Println("Error loading config:", err) |
| 39 | 39 | return |
| 40 | 40 | } |
| 41 | internal.SetGlobalConfig(&userCurdConfig) | |
| 41 | 42 | |
| 42 | 43 | logFile := filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "debug.log") |
| 43 | 44 | internal.ClearLogFile(logFile) |
| @@ -59,11 +60,12 @@ func main() { | ||
| 59 | 60 | flag.BoolVar(&userCurdConfig.DiscordPresence, "discord-presence", userCurdConfig.DiscordPresence, "Enable Discord presence (true/false)") |
| 60 | 61 | continueLast := flag.Bool("c", false, "Continue last episode") |
| 61 | 62 | addNewAnime := flag.Bool("new", false, "Add new anime") |
| 63 | rofiSelection := flag.Bool("rofi", false, "Open selection in rofi") | |
| 62 | 64 | updateScript := flag.Bool("u", false, "Update the script") |
| 63 | 65 | editConfig := flag.Bool("e", false, "Edit config") |
| 64 | 66 | subFlag := flag.Bool("sub", false, "Watch sub version") |
| 65 | 67 | dubFlag := flag.Bool("dub", false, "Watch dub version") |
| 66 | ||
| 68 | ||
| 67 | 69 | // Custom help/usage function |
| 68 | 70 | flag.Usage = func() { |
| 69 | 71 | fmt.Fprintf(os.Stderr, "Curd is a CLI tool to manage anime playback with advanced features like skipping intro, outro, filler, recap, tracking progress, and integrating with Discord.\n") |
| @@ -72,34 +74,38 @@ func main() { | ||
| 72 | 74 | } |
| 73 | 75 | |
| 74 | 76 | flag.Parse() |
| 75 | ||
| 77 | ||
| 76 | 78 | anime.Ep.ContinueLast = *continueLast |
| 77 | 79 | |
| 78 | if *updateScript{ | |
| 80 | if *updateScript { | |
| 79 | 81 | repo := "wraient/curd" |
| 80 | 82 | fileName := "curd" |
| 81 | ||
| 83 | ||
| 82 | 84 | if err := internal.UpdateCurd(repo, fileName); err != nil { |
| 83 | fmt.Printf("Error updating executable: %v\n", err) | |
| 85 | internal.CurdOut(fmt.Sprintf("Error updating executable: %v\n", err)) | |
| 84 | 86 | internal.ExitCurd(err) |
| 85 | 87 | } else { |
| 86 | fmt.Println("Program Updated!") | |
| 88 | internal.CurdOut("Program Updated!") | |
| 87 | 89 | internal.ExitCurd(nil) |
| 88 | 90 | } |
| 89 | 91 | } |
| 90 | 92 | |
| 93 | if *rofiSelection { | |
| 94 | userCurdConfig.RofiSelection = true | |
| 95 | } | |
| 96 | ||
| 91 | 97 | if *editConfig { |
| 92 | 98 | internal.EditConfig(configFilePath) |
| 93 | 99 | return |
| 94 | 100 | } |
| 95 | ||
| 101 | ||
| 96 | 102 | // Set SubOrDub based on the flags |
| 97 | 103 | if *subFlag { |
| 98 | 104 | userCurdConfig.SubOrDub = "sub" |
| 99 | } else if *dubFlag { | |
| 100 | userCurdConfig.SubOrDub = "dub" | |
| 101 | } | |
| 102 | ||
| 105 | } else if *dubFlag { | |
| 106 | userCurdConfig.SubOrDub = "dub" | |
| 107 | } | |
| 108 | ||
| 103 | 109 | // Get the token from the token file |
| 104 | 110 | user.Token, err = internal.GetTokenFromFile(filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "token")) |
| 105 | 111 | if err != nil { |
| @@ -110,29 +116,29 @@ func main() { | ||
| 110 | 116 | fmt.Scanln(&user.Token) |
| 111 | 117 | internal.WriteTokenToFile(user.Token, filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "token")) |
| 112 | 118 | } |
| 113 | ||
| 119 | ||
| 114 | 120 | // Load animes in database |
| 115 | 121 | databaseFile := filepath.Join(os.ExpandEnv(userCurdConfig.StoragePath), "curd_history.txt") |
| 116 | 122 | databaseAnimes := internal.LocalGetAllAnime(databaseFile) |
| 117 | ||
| 123 | ||
| 118 | 124 | if *addNewAnime { |
| 119 | 125 | internal.AddNewAnime(&userCurdConfig, &anime, &user, &databaseAnimes, logFile) |
| 120 | 126 | internal.ExitCurd(fmt.Errorf("Added new anime!")) |
| 121 | 127 | } |
| 122 | 128 | |
| 123 | 129 | internal.SetupCurd(&userCurdConfig, &anime, &user, &databaseAnimes, logFile) |
| 124 | ||
| 130 | ||
| 125 | 131 | temp_anime, err := internal.FindAnimeByAnilistID(user.AnimeList, strconv.Itoa(anime.AnilistId)) |
| 126 | 132 | if err != nil { |
| 127 | 133 | internal.Log("Error finding anime by Anilist ID: "+err.Error(), logFile) |
| 128 | 134 | } |
| 129 | ||
| 135 | ||
| 130 | 136 | if anime.TotalEpisodes == temp_anime.Progress { |
| 131 | 137 | internal.Log(temp_anime.Progress, logFile) |
| 132 | 138 | internal.Log(anime.TotalEpisodes, logFile) |
| 133 | 139 | internal.Log(user.AnimeList, logFile) |
| 134 | 140 | internal.Log("Rewatching anime: "+internal.GetAnimeName(anime), logFile) |
| 135 | anime.Rewatching = true | |
| 141 | anime.Rewatching = true | |
| 136 | 142 | } |
| 137 | 143 | |
| 138 | 144 | anime.Ep.Player.Speed = 1.0 |
| @@ -168,7 +174,7 @@ func main() { | ||
| 168 | 174 | internal.Log(fmt.Sprint("Playback starting time: ", anime.Ep.Player.PlaybackTime), logFile) |
| 169 | 175 | internal.Log(anime.Ep.Player.SocketPath, logFile) |
| 170 | 176 | } else { |
| 171 | fmt.Println("Filler episode, skipping: ", anime.Ep.Number) | |
| 177 | internal.CurdOut(fmt.Sprint("Filler episode, skipping: ", anime.Ep.Number)) | |
| 172 | 178 | } |
| 173 | 179 | |
| 174 | 180 | wg.Add(1) |
| @@ -184,12 +190,12 @@ func main() { | ||
| 184 | 190 | // if filler episode or recap episode and skip is enabled |
| 185 | 191 | if (userCurdConfig.SkipFiller || userCurdConfig.SkipRecap) && (anime.Ep.IsFiller || anime.Ep.IsRecap) { |
| 186 | 192 | if anime.Ep.IsFiller && userCurdConfig.SkipFiller { |
| 187 | fmt.Println("Filler Episode, starting next episode: ", anime.Ep.Number+1) | |
| 193 | internal.CurdOut(fmt.Sprint("Filler Episode, starting next episode: ", anime.Ep.Number+1)) | |
| 188 | 194 | internal.Log("Filler episode detected", logFile) |
| 189 | 195 | } else if anime.Ep.IsRecap && userCurdConfig.SkipRecap { |
| 190 | fmt.Println("Recap Episode, starting next episode: ", anime.Ep.Number+1) | |
| 196 | internal.CurdOut(fmt.Sprint("Recap Episode, starting next episode: ", anime.Ep.Number+1)) | |
| 191 | 197 | internal.Log("Recap episode detected", logFile) |
| 192 | } | |
| 198 | } | |
| 193 | 199 | anime.Ep.Number++ |
| 194 | 200 | anime.Ep.Started = false |
| 195 | 201 | anime.Ep.IsCompleted = true |
| @@ -202,7 +208,7 @@ func main() { | ||
| 202 | 208 | } |
| 203 | 209 | // Exit the skip loop |
| 204 | 210 | close(skipLoopDone) |
| 205 | } | |
| 211 | } | |
| 206 | 212 | } |
| 207 | 213 | }() |
| 208 | 214 | |
| @@ -244,15 +250,15 @@ func main() { | ||
| 244 | 250 | durationPos, err := internal.MPVSendCommand(anime.Ep.Player.SocketPath, []interface{}{"get_property", "duration"}) |
| 245 | 251 | if err != nil { |
| 246 | 252 | internal.Log("Error getting video duration: "+err.Error(), logFile) |
| 247 | } else if durationPos != nil { | |
| 248 | if duration, ok := durationPos.(float64); ok { | |
| 249 | anime.Ep.Duration = int(duration + 0.5) // Round to nearest integer | |
| 250 | internal.Log(fmt.Sprintf("Video duration: %d seconds", anime.Ep.Duration), logFile) | |
| 251 | } else { | |
| 253 | } else if durationPos != nil { | |
| 254 | if duration, ok := durationPos.(float64); ok { | |
| 255 | anime.Ep.Duration = int(duration + 0.5) // Round to nearest integer | |
| 256 | internal.Log(fmt.Sprintf("Video duration: %d seconds", anime.Ep.Duration), logFile) | |
| 257 | } else { | |
| 252 | 258 | internal.Log("Error: duration is not a float64", logFile) |
| 253 | 259 | } |
| 254 | 260 | } |
| 255 | break | |
| 261 | break | |
| 256 | 262 | } |
| 257 | 263 | } |
| 258 | 264 | time.Sleep(1 * time.Second) |
| @@ -375,7 +381,7 @@ func main() { | ||
| 375 | 381 | wg = sync.WaitGroup{} |
| 376 | 382 | |
| 377 | 383 | if anime.Ep.IsCompleted && !anime.Rewatching { |
| 378 | go func(){ | |
| 384 | go func() { | |
| 379 | 385 | err = internal.UpdateAnimeProgress(user.Token, anime.AnilistId, anime.Ep.Number-1) |
| 380 | 386 | if err != nil { |
| 381 | 387 | internal.Log("Error updating Anilist progress: "+err.Error(), logFile) |
| @@ -383,11 +389,11 @@ func main() { | ||
| 383 | 389 | }() |
| 384 | 390 | |
| 385 | 391 | anime.Ep.IsCompleted = false |
| 386 | // fmt.Println(anime.Ep.Number, anime.TotalEpisodes) | |
| 392 | // internal.CurdOut(anime.Ep.Number, anime.TotalEpisodes, &userCurdConfig) | |
| 387 | 393 | if anime.Ep.Number-1 == anime.TotalEpisodes && userCurdConfig.ScoreOnCompletion { |
| 388 | 394 | anime.Ep.Number = anime.Ep.Number - 1 |
| 389 | 395 | var userScore float64 |
| 390 | fmt.Println("Completed anime.") | |
| 396 | internal.CurdOut("Completed anime.") | |
| 391 | 397 | fmt.Println("Rate this anime: ") |
| 392 | 398 | fmt.Scanln(&userScore) |
| 393 | 399 | internal.RateAnime(user.Token, anime.AnilistId, userScore) |
| @@ -397,7 +403,7 @@ func main() { | ||
| 397 | 403 | } |
| 398 | 404 | if anime.Rewatching && anime.Ep.IsCompleted && anime.Ep.Number-1 == anime.TotalEpisodes { |
| 399 | 405 | anime.Ep.Number = anime.Ep.Number - 1 |
| 400 | fmt.Println("Completed anime. (Rewatching so no scoring)") | |
| 406 | internal.CurdOut("Completed anime. (Rewatching so no scoring)") | |
| 401 | 407 | internal.LocalDeleteAnime(databaseFile, anime.AnilistId, anime.AllanimeId) |
| 402 | 408 | internal.ExitCurd(nil) |
| 403 | 409 | } |
| @@ -411,9 +417,9 @@ func main() { | ||
| 411 | 417 | internal.ExitCurd(nil) |
| 412 | 418 | } |
| 413 | 419 | } |
| 414 | ||
| 415 | fmt.Println("Starting next episode: "+fmt.Sprint(anime.Ep.Number)) | |
| 416 | anime.Ep.Started = false | |
| 420 | ||
| 421 | internal.CurdOut(fmt.Sprint("Starting next episode: ", anime.Ep.Number)) | |
| 422 | anime.Ep.Started = false | |
| 417 | 423 | |
| 418 | 424 | } |
| 419 | } | |
| \ No newline at end of file | ||
| 425 | } | |
go.mod +5
| @@ -5,6 +5,7 @@ go 1.23.2 | ||
| 5 | 5 | require ( |
| 6 | 6 | github.com/Microsoft/go-winio v0.6.2 |
| 7 | 7 | github.com/charmbracelet/bubbletea v1.1.1 |
| 8 | github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 | |
| 8 | 9 | github.com/hugolgst/rich-go v0.0.0-20240715122152-74618cc1ace2 |
| 9 | 10 | ) |
| 10 | 11 | |
| @@ -14,6 +15,8 @@ require ( | ||
| 14 | 15 | github.com/charmbracelet/x/ansi v0.2.3 // indirect |
| 15 | 16 | github.com/charmbracelet/x/term v0.2.0 // indirect |
| 16 | 17 | github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect |
| 18 | github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect | |
| 19 | github.com/godbus/dbus/v5 v5.1.0 // indirect | |
| 17 | 20 | github.com/lucasb-eyer/go-colorful v1.2.0 // indirect |
| 18 | 21 | github.com/mattn/go-isatty v0.0.20 // indirect |
| 19 | 22 | github.com/mattn/go-localereader v0.0.1 // indirect |
| @@ -21,7 +24,9 @@ require ( | ||
| 21 | 24 | github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect |
| 22 | 25 | github.com/muesli/cancelreader v0.2.2 // indirect |
| 23 | 26 | github.com/muesli/termenv v0.15.2 // indirect |
| 27 | github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect | |
| 24 | 28 | github.com/rivo/uniseg v0.4.7 // indirect |
| 29 | github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect | |
| 25 | 30 | golang.org/x/sync v0.8.0 // indirect |
| 26 | 31 | golang.org/x/sys v0.24.0 // indirect |
| 27 | 32 | golang.org/x/text v0.14.0 // indirect |
go.sum +10
| @@ -12,6 +12,12 @@ github.com/charmbracelet/x/term v0.2.0 h1:cNB9Ot9q8I711MyZ7myUR5HFWL/lc3OpU8jZ4h | ||
| 12 | 12 | github.com/charmbracelet/x/term v0.2.0/go.mod h1:GVxgxAbjUrmpvIINHIQnJJKpMlHiZ4cktEQCN6GWyF0= |
| 13 | 13 | github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4= |
| 14 | 14 | github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM= |
| 15 | github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4 h1:ygs9POGDQpQGLJPlq4+0LBUmMBNox1N4JSpw+OETcvI= | |
| 16 | github.com/gen2brain/beeep v0.0.0-20240516210008-9c006672e7f4/go.mod h1:0W7dI87PvXJ1Sjs0QPvWXKcQmNERY77e8l7GFhZB/s4= | |
| 17 | github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/OqtnntR4DfOY2+BgwR60cAcu/i3SE= | |
| 18 | github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4/go.mod h1:kW3HQ4UdaAyrUCSSDR4xUzBKW6O2iA4uHhk7AtyYp10= | |
| 19 | github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= | |
| 20 | github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= | |
| 15 | 21 | github.com/hugolgst/rich-go v0.0.0-20240715122152-74618cc1ace2 h1:9qOViOQGFIP5ar+2NorfAIsfuADEKXtklySC0zNnYf4= |
| 16 | 22 | github.com/hugolgst/rich-go v0.0.0-20240715122152-74618cc1ace2/go.mod h1:nGaW7CGfNZnhtiFxMpc4OZdqIexGXjUlBnlmpZmjEKA= |
| 17 | 23 | github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= |
| @@ -28,9 +34,13 @@ github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELU | ||
| 28 | 34 | github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo= |
| 29 | 35 | github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo= |
| 30 | 36 | github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8= |
| 37 | github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ= | |
| 38 | github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= | |
| 31 | 39 | github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= |
| 32 | 40 | github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= |
| 33 | 41 | github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= |
| 42 | github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG04SN9W+iWHCRyHqlVYILiSXziwk= | |
| 43 | github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o= | |
| 34 | 44 | golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= |
| 35 | 45 | golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= |
| 36 | 46 | golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
internal/anilist.go +4 −4
| @@ -177,7 +177,7 @@ func AddAnimeToWatchingList(animeID int, token string) error { | ||
| 177 | 177 | return fmt.Errorf("failed to add anime: %w", err) |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | fmt.Printf("Anime with ID %d has been added to your watching list.\n", animeID) | |
| 180 | CurdOut(fmt.Sprintf("Anime with ID %d has been added to your watching list.", animeID)) | |
| 181 | 181 | return nil |
| 182 | 182 | } |
| 183 | 183 | |
| @@ -344,7 +344,7 @@ func UpdateAnimeProgress(token string, mediaID, progress int) error { | ||
| 344 | 344 | return err |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | fmt.Println("Anime progress updated! Latest watched episode:", progress) | |
| 347 | CurdOut(fmt.Sprint("Anime progress updated! Latest watched episode: ", progress)) | |
| 348 | 348 | return nil |
| 349 | 349 | } |
| 350 | 350 | |
| @@ -375,7 +375,7 @@ func RateAnime(token string, mediaID int, score float64) error { | ||
| 375 | 375 | return err |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | fmt.Printf("Successfully rated anime (mediaId: %d) with score: %.2f\n", mediaID, score) | |
| 378 | CurdOut(fmt.Sprintf("Successfully rated anime (mediaId: %d) with score: %.2f", mediaID, score)) | |
| 379 | 379 | return nil |
| 380 | 380 | } |
| 381 | 381 | |
| @@ -456,7 +456,7 @@ func ParseAnimeList(input map[string]interface{}) AnimeList { | ||
| 456 | 456 | // Access the list entries in the input map |
| 457 | 457 | if input["data"] == nil { |
| 458 | 458 | Log("Anilist request failed", logFile) |
| 459 | fmt.Println("Anilist request failed") | |
| 459 | CurdOut("Anilist request failed") | |
| 460 | 460 | ExitCurd(fmt.Errorf("Anilist request failed")) |
| 461 | 461 | return animeList |
| 462 | 462 | } |
internal/config.go +33 −20
| @@ -22,11 +22,43 @@ type CurdConfig struct { | ||
| 22 | 22 | SkipEd bool `config:"SkipEd"` |
| 23 | 23 | SkipFiller bool `config:"SkipFiller"` |
| 24 | 24 | SkipRecap bool `config:"SkipRecap"` |
| 25 | RofiSelection bool `config:"RofiSelection"` | |
| 25 | 26 | ScoreOnCompletion bool `config:"ScoreOnCompletion"` |
| 26 | 27 | SaveMpvSpeed bool `config:"SaveMpvSpeed"` |
| 27 | 28 | DiscordPresence bool `config:"DiscordPresence"` |
| 28 | 29 | } |
| 29 | 30 | |
| 31 | // Default configuration values as a map | |
| 32 | func defaultConfigMap() map[string]string { | |
| 33 | return map[string]string{ | |
| 34 | "Player": "mpv", | |
| 35 | "StoragePath": "$HOME/.local/share/curd", | |
| 36 | "SubsLanguage": "english", | |
| 37 | "SubOrDub": "sub", | |
| 38 | "PercentageToMarkComplete": "85", | |
| 39 | "NextEpisodePrompt": "false", | |
| 40 | "SkipOp": "true", | |
| 41 | "SkipEd": "true", | |
| 42 | "SkipFiller": "true", | |
| 43 | "SkipRecap": "true", | |
| 44 | "RofiSelection": "false", | |
| 45 | "ScoreOnCompletion": "true", | |
| 46 | "SaveMpvSpeed": "true", | |
| 47 | "DiscordPresence": "true", | |
| 48 | } | |
| 49 | } | |
| 50 | ||
| 51 | var globalConfig *CurdConfig | |
| 52 | ||
| 53 | func SetGlobalConfig(config *CurdConfig) { | |
| 54 | globalConfig = config | |
| 55 | } | |
| 56 | ||
| 57 | func GetGlobalConfig() *CurdConfig { | |
| 58 | return globalConfig | |
| 59 | } | |
| 60 | ||
| 61 | ||
| 30 | 62 | // LoadConfig reads or creates the config file, adds missing fields, and returns the populated CurdConfig struct |
| 31 | 63 | func LoadConfig(configPath string) (CurdConfig, error) { |
| 32 | 64 | configPath = os.ExpandEnv(configPath) // Substitute environment variables like $HOME |
| @@ -34,7 +66,7 @@ func LoadConfig(configPath string) (CurdConfig, error) { | ||
| 34 | 66 | // Check if config file exists |
| 35 | 67 | if _, err := os.Stat(configPath); os.IsNotExist(err) { |
| 36 | 68 | // Create the config file with default values if it doesn't exist |
| 37 | fmt.Println("Config file not found. Creating default config...") | |
| 69 | CurdOut("Config file not found. Creating default config...") | |
| 38 | 70 | if err := createDefaultConfig(configPath); err != nil { |
| 39 | 71 | return CurdConfig{}, fmt.Errorf("error creating default config file: %v", err) |
| 40 | 72 | } |
| @@ -69,25 +101,6 @@ func LoadConfig(configPath string) (CurdConfig, error) { | ||
| 69 | 101 | return config, nil |
| 70 | 102 | } |
| 71 | 103 | |
| 72 | // Default configuration values as a map | |
| 73 | func defaultConfigMap() map[string]string { | |
| 74 | return map[string]string{ | |
| 75 | "Player": "mpv", | |
| 76 | "StoragePath": "$HOME/.local/share/curd", | |
| 77 | "SubsLanguage": "english", | |
| 78 | "SubOrDub": "sub", | |
| 79 | "PercentageToMarkComplete": "85", | |
| 80 | "NextEpisodePrompt": "false", | |
| 81 | "SkipOp": "true", | |
| 82 | "SkipEd": "true", | |
| 83 | "SkipFiller": "true", | |
| 84 | "SkipRecap": "true", | |
| 85 | "ScoreOnCompletion": "true", | |
| 86 | "SaveMpvSpeed": "true", | |
| 87 | "DiscordPresence": "true", | |
| 88 | } | |
| 89 | } | |
| 90 | ||
| 91 | 104 | // Create a config file with default values in key=value format |
| 92 | 105 | // Ensure the directory exists before creating the file |
| 93 | 106 | func createDefaultConfig(path string) error { |
internal/curd.go +43 −16
| @@ -7,6 +7,7 @@ import ( | ||
| 7 | 7 | "net/http" |
| 8 | 8 | "os" |
| 9 | 9 | "os/exec" |
| 10 | "github.com/gen2brain/beeep" | |
| 10 | 11 | "path/filepath" |
| 11 | 12 | "regexp" |
| 12 | 13 | "runtime" |
| @@ -47,11 +48,11 @@ func EditConfig(configFilePath string) { | ||
| 47 | 48 | // Run the editor command |
| 48 | 49 | err := cmd.Run() |
| 49 | 50 | if err != nil { |
| 50 | fmt.Printf("Error opening config file: %v\n", err) | |
| 51 | CurdOut(fmt.Sprintf("Error opening config file: %v", err)) | |
| 51 | 52 | return |
| 52 | 53 | } |
| 53 | 54 | |
| 54 | fmt.Println("Config file edited successfully.") | |
| 55 | CurdOut("Config file edited successfully.") | |
| 55 | 56 | } |
| 56 | 57 | |
| 57 | 58 | // ClearLogFile removes all contents from the specified log file |
| @@ -112,21 +113,47 @@ func RestoreScreen() { | ||
| 112 | 113 | |
| 113 | 114 | func ExitCurd(err error) { |
| 114 | 115 | RestoreScreen() |
| 116 | CurdOut("Have a great day!") | |
| 115 | 117 | if err != nil { |
| 116 | fmt.Println(err) | |
| 118 | CurdOut(err) | |
| 117 | 119 | if runtime.GOOS == "windows" { |
| 118 | 120 | fmt.Println("Press Enter to exit") |
| 119 | 121 | var wait string |
| 120 | 122 | fmt.Scanln(&wait) |
| 121 | 123 | os.Exit(1) |
| 122 | 124 | } else { |
| 123 | fmt.Println("Have a great day!") | |
| 124 | 125 | os.Exit(1) |
| 125 | 126 | } |
| 126 | 127 | } |
| 127 | 128 | os.Exit(0) |
| 128 | 129 | } |
| 129 | 130 | |
| 131 | func CurdOut(data interface{}) { | |
| 132 | userCurdConfig := GetGlobalConfig() | |
| 133 | if !userCurdConfig.RofiSelection { | |
| 134 | fmt.Println(fmt.Sprintf("%v", data)) | |
| 135 | } else { | |
| 136 | switch runtime.GOOS { | |
| 137 | case "windows": | |
| 138 | err := beeep.Notify( | |
| 139 | "Curd", | |
| 140 | fmt.Sprintf("%v", data), | |
| 141 | "", | |
| 142 | ) | |
| 143 | ||
| 144 | if err != nil { | |
| 145 | Log(fmt.Sprintf("Failed to send notification: %v", err), logFile) | |
| 146 | } | |
| 147 | case "linux": | |
| 148 | cmd := exec.Command("notify-send", fmt.Sprintf("%v", data)) | |
| 149 | err := cmd.Run() | |
| 150 | if err != nil { | |
| 151 | Log(fmt.Sprintf("Failed to send notification: %v", err), logFile) | |
| 152 | } | |
| 153 | } | |
| 154 | } | |
| 155 | } | |
| 156 | ||
| 130 | 157 | func UpdateCurd(repo, fileName string) error { |
| 131 | 158 | // Get the path of the currently running executable |
| 132 | 159 | executablePath, err := os.Executable() |
| @@ -177,7 +204,7 @@ func UpdateCurd(repo, fileName string) error { | ||
| 177 | 204 | if err := os.Rename(tmpPath, executablePath); err != nil { |
| 178 | 205 | return fmt.Errorf("failed to replace the current executable: %v", err) |
| 179 | 206 | } |
| 180 | fmt.Println("Downloaded curd executable to", executablePath) | |
| 207 | CurdOut(fmt.Sprintf("Downloaded curd executable to %v", executablePath)) | |
| 181 | 208 | |
| 182 | 209 | if runtime.GOOS != "windows" { |
| 183 | 210 | // Ensure the new file has executable permissions |
| @@ -190,7 +217,7 @@ func UpdateCurd(repo, fileName string) error { | ||
| 190 | 217 | } |
| 191 | 218 | |
| 192 | 219 | func AddNewAnime(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAnimes *[]Anime, logFile string) { |
| 193 | fmt.Println("Enter the anime name:") | |
| 220 | CurdOut("Enter the anime name:") | |
| 194 | 221 | var query string |
| 195 | 222 | fmt.Scanln(&query) |
| 196 | 223 | animeMap, err := SearchAnimeAnilist(query, user.Token) |
| @@ -318,7 +345,7 @@ func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAni | ||
| 318 | 345 | |
| 319 | 346 | // If unable to get Allanime id automatically get manually |
| 320 | 347 | if anime.AllanimeId == "" { |
| 321 | fmt.Println("Failed to automatically select anime") | |
| 348 | CurdOut("Failed to automatically select anime") | |
| 322 | 349 | selectedAllanimeAnime, err := DynamicSelect(animeList) |
| 323 | 350 | if err != nil { |
| 324 | 351 | // fmt.Println("No anime available") |
| @@ -357,17 +384,17 @@ func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAni | ||
| 357 | 384 | } |
| 358 | 385 | |
| 359 | 386 | if anime.TotalEpisodes == 0 { // If failed to get anime data |
| 360 | fmt.Println("Failed to get anime data. Attempting to retrieve from anime list.") | |
| 387 | CurdOut("Failed to get anime data. Attempting to retrieve from anime list.") | |
| 361 | 388 | animeList, err := SearchAnime(string(userQuery), userCurdConfig.SubOrDub) |
| 362 | 389 | if err != nil { |
| 363 | fmt.Println("Failed to retrieve anime list:", err) | |
| 390 | CurdOut(fmt.Sprintf("Failed to retrieve anime list: %v", err)) | |
| 364 | 391 | } else { |
| 365 | 392 | for allanimeId, label := range animeList { |
| 366 | 393 | if allanimeId == anime.AllanimeId { |
| 367 | 394 | // Extract total episodes from the label |
| 368 | 395 | if matches := regexp.MustCompile(`\((\d+) episodes\)`).FindStringSubmatch(label); len(matches) > 1 { |
| 369 | 396 | anime.TotalEpisodes, _ = strconv.Atoi(matches[1]) |
| 370 | fmt.Printf("Retrieved total episodes: %d\n", anime.TotalEpisodes) | |
| 397 | CurdOut(fmt.Sprintf("Retrieved total episodes: %d", anime.TotalEpisodes)) | |
| 371 | 398 | break |
| 372 | 399 | } |
| 373 | 400 | } |
| @@ -375,8 +402,8 @@ func SetupCurd(userCurdConfig *CurdConfig, anime *Anime, user *User, databaseAni | ||
| 375 | 402 | } |
| 376 | 403 | |
| 377 | 404 | if anime.TotalEpisodes == 0 { |
| 378 | fmt.Println("Still unable to determine total episodes.") | |
| 379 | fmt.Println("Your AniList progress:", selectedAnilistAnime.Progress) | |
| 405 | CurdOut("Still unable to determine total episodes.") | |
| 406 | CurdOut(fmt.Sprintf("Your AniList progress: %d", selectedAnilistAnime.Progress)) | |
| 380 | 407 | fmt.Print("Enter the episode you want to start from: ") |
| 381 | 408 | var episodeNumber int |
| 382 | 409 | fmt.Scanln(&episodeNumber) |
| @@ -425,15 +452,15 @@ func StartCurd(userCurdConfig *CurdConfig, anime *Anime, logFile string) string | ||
| 425 | 452 | // If unable to get episode link automatically get manually |
| 426 | 453 | episodeList, err := EpisodesList(anime.AllanimeId, userCurdConfig.SubOrDub) |
| 427 | 454 | if err != nil { |
| 428 | fmt.Println("No episode list found") | |
| 455 | CurdOut("No episode list found") | |
| 429 | 456 | RestoreScreen() |
| 430 | 457 | os.Exit(1) |
| 431 | 458 | } |
| 432 | fmt.Printf("Enter the episode (%v episodes)\n", episodeList[len(episodeList)-1]) | |
| 459 | CurdOut(fmt.Sprintf("Enter the episode (%v episodes)", episodeList[len(episodeList)-1])) | |
| 433 | 460 | fmt.Scanln(&anime.Ep.Number) |
| 434 | 461 | link, err = GetEpisodeURL(*userCurdConfig, anime.AllanimeId, anime.Ep.Number) |
| 435 | 462 | if err != nil { |
| 436 | fmt.Println("Failed to get episode link") | |
| 463 | CurdOut("Failed to get episode link") | |
| 437 | 464 | os.Exit(1) |
| 438 | 465 | } |
| 439 | 466 | // anime.Ep.Links = link |
| @@ -441,7 +468,7 @@ func StartCurd(userCurdConfig *CurdConfig, anime *Anime, logFile string) string | ||
| 441 | 468 | anime.Ep.Links = link |
| 442 | 469 | |
| 443 | 470 | if len(anime.Ep.Links) == 0 { |
| 444 | fmt.Println("No episode links found") | |
| 471 | CurdOut("No episode links found") | |
| 445 | 472 | os.Exit(1) |
| 446 | 473 | } |
| 447 | 474 | |
internal/localTracking.go +14 −14
| @@ -12,7 +12,7 @@ import ( | ||
| 12 | 12 | func LocalAddAnime(databaseFile string, anilistID int, allanimeID string, watchingEpisode int, watchingTime int, animeDuration int, animeName string) { |
| 13 | 13 | file, err := os.OpenFile(databaseFile, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644) |
| 14 | 14 | if err != nil { |
| 15 | fmt.Println("Error opening file:", err) | |
| 15 | CurdOut(fmt.Sprintf("Error opening file: %v", err)) | |
| 16 | 16 | return |
| 17 | 17 | } |
| 18 | 18 | defer file.Close() |
| @@ -29,9 +29,9 @@ func LocalAddAnime(databaseFile string, anilistID int, allanimeID string, watchi | ||
| 29 | 29 | animeName, |
| 30 | 30 | }) |
| 31 | 31 | if err != nil { |
| 32 | fmt.Println("Error writing to file:", err) | |
| 32 | CurdOut(fmt.Sprintf("Error writing to file: %v", err)) | |
| 33 | 33 | } else { |
| 34 | fmt.Println("Written to file") | |
| 34 | CurdOut("Written to file") | |
| 35 | 35 | } |
| 36 | 36 | } |
| 37 | 37 | |
| @@ -40,7 +40,7 @@ func LocalDeleteAnime(databaseFile string, anilistID int, allanimeID string) { | ||
| 40 | 40 | animeList := [][]string{} |
| 41 | 41 | file, err := os.Open(databaseFile) |
| 42 | 42 | if err != nil { |
| 43 | fmt.Println("Error opening file:", err) | |
| 43 | CurdOut(fmt.Sprintf("Error opening file: %v", err)) | |
| 44 | 44 | return |
| 45 | 45 | } |
| 46 | 46 | defer file.Close() |
| @@ -48,7 +48,7 @@ func LocalDeleteAnime(databaseFile string, anilistID int, allanimeID string) { | ||
| 48 | 48 | reader := csv.NewReader(file) |
| 49 | 49 | records, err := reader.ReadAll() |
| 50 | 50 | if err != nil { |
| 51 | fmt.Println("Error reading file:", err) | |
| 51 | CurdOut(fmt.Sprintf("Error reading file: %v", err)) | |
| 52 | 52 | return |
| 53 | 53 | } |
| 54 | 54 | |
| @@ -63,7 +63,7 @@ func LocalDeleteAnime(databaseFile string, anilistID int, allanimeID string) { | ||
| 63 | 63 | // Write the filtered list back to the file |
| 64 | 64 | fileWrite, err := os.OpenFile(databaseFile, os.O_WRONLY|os.O_TRUNC, 0644) |
| 65 | 65 | if err != nil { |
| 66 | fmt.Println("Error opening file for writing:", err) | |
| 66 | CurdOut(fmt.Sprintf("Error opening file for writing: %v", err)) | |
| 67 | 67 | return |
| 68 | 68 | } |
| 69 | 69 | defer fileWrite.Close() |
| @@ -73,7 +73,7 @@ func LocalDeleteAnime(databaseFile string, anilistID int, allanimeID string) { | ||
| 73 | 73 | |
| 74 | 74 | err = writer.WriteAll(animeList) |
| 75 | 75 | if err != nil { |
| 76 | fmt.Println("Error writing to file:", err) | |
| 76 | CurdOut(fmt.Sprintf("Error writing to file: %v", err)) | |
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
| @@ -84,14 +84,14 @@ func LocalGetAllAnime(databaseFile string) []Anime { | ||
| 84 | 84 | // Ensure the directory exists |
| 85 | 85 | dir := filepath.Dir(databaseFile) |
| 86 | 86 | if err := os.MkdirAll(dir, 0755); err != nil { |
| 87 | fmt.Println("Error creating directory:", err) | |
| 87 | CurdOut(fmt.Sprintf("Error creating directory: %v", err)) | |
| 88 | 88 | return animeList |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // Open the file, create if it doesn't exist |
| 92 | 92 | file, err := os.OpenFile(databaseFile, os.O_RDONLY|os.O_CREATE, 0644) |
| 93 | 93 | if err != nil { |
| 94 | fmt.Println("Error opening or creating file:", err) | |
| 94 | CurdOut(fmt.Sprintf("Error opening or creating file: %v", err)) | |
| 95 | 95 | return animeList |
| 96 | 96 | } |
| 97 | 97 | defer file.Close() |
| @@ -99,7 +99,7 @@ func LocalGetAllAnime(databaseFile string) []Anime { | ||
| 99 | 99 | // If the file was just created, it will be empty, so return an empty list |
| 100 | 100 | fileInfo, err := file.Stat() |
| 101 | 101 | if err != nil { |
| 102 | fmt.Println("Error getting file info:", err) | |
| 102 | CurdOut(fmt.Sprintf("Error getting file info: %v", err)) | |
| 103 | 103 | return animeList |
| 104 | 104 | } |
| 105 | 105 | if fileInfo.Size() == 0 { |
| @@ -109,7 +109,7 @@ func LocalGetAllAnime(databaseFile string) []Anime { | ||
| 109 | 109 | reader := csv.NewReader(file) |
| 110 | 110 | records, err := reader.ReadAll() |
| 111 | 111 | if err != nil { |
| 112 | fmt.Println("Error reading file:", err) | |
| 112 | CurdOut(fmt.Sprintf("Error reading file: %v", err)) | |
| 113 | 113 | return animeList |
| 114 | 114 | } |
| 115 | 115 | |
| @@ -126,7 +126,7 @@ func LocalGetAllAnime(databaseFile string) []Anime { | ||
| 126 | 126 | // Function to parse a single row of anime data |
| 127 | 127 | func parseAnimeRow(row []string) *Anime { |
| 128 | 128 | if len(row) < 5 { |
| 129 | fmt.Printf("Invalid row format: %v\n", row) | |
| 129 | CurdOut(fmt.Sprintf("Invalid row format: %v", row)) | |
| 130 | 130 | return nil |
| 131 | 131 | } |
| 132 | 132 | |
| @@ -211,7 +211,7 @@ func LocalUpdateAnime(databaseFile string, anilistID int, allanimeID string, wat | ||
| 211 | 211 | // Write updated list back to file |
| 212 | 212 | file, err := os.Create(databaseFile) |
| 213 | 213 | if err != nil { |
| 214 | fmt.Println("Error creating file:", err) | |
| 214 | CurdOut(fmt.Sprintf("Error creating file: %v", err)) | |
| 215 | 215 | return err |
| 216 | 216 | } |
| 217 | 217 | defer file.Close() |
| @@ -229,7 +229,7 @@ func LocalUpdateAnime(databaseFile string, anilistID int, allanimeID string, wat | ||
| 229 | 229 | GetAnimeName(anime), |
| 230 | 230 | } |
| 231 | 231 | if err := writer.Write(record); err != nil { |
| 232 | fmt.Println("Error writing record:", err) | |
| 232 | CurdOut(fmt.Sprintf("Error writing record: %v", err)) | |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
internal/player.go +2 −2
| @@ -56,7 +56,7 @@ func StartVideo(link string, args []string) (string, error) { | ||
| 56 | 56 | // Get the path to mpv.exe for Windows |
| 57 | 57 | mpvPath, err := getMPVPath() |
| 58 | 58 | if err != nil { |
| 59 | fmt.Println("Error: Failed to get MPV path") | |
| 59 | CurdOut("Error: Failed to get MPV path") | |
| 60 | 60 | Log("Failed to get mpv path.", logFile) |
| 61 | 61 | return "", err |
| 62 | 62 | } |
| @@ -71,7 +71,7 @@ func StartVideo(link string, args []string) (string, error) { | ||
| 71 | 71 | // Start the mpv process |
| 72 | 72 | err = command.Start() |
| 73 | 73 | if err != nil { |
| 74 | fmt.Println("Error: Failed to start mpv process") | |
| 74 | CurdOut("Error: Failed to start mpv process") | |
| 75 | 75 | return "", fmt.Errorf("failed to start mpv: %w", err) |
| 76 | 76 | } |
| 77 | 77 | return mpvSocketPath, nil |
internal/selection_menu.go +62 −1
| @@ -1,7 +1,9 @@ | ||
| 1 | 1 | package internal |
| 2 | 2 | |
| 3 | 3 | import ( |
| 4 | "bytes" | |
| 4 | 5 | "fmt" |
| 6 | "os/exec" | |
| 5 | 7 | "sort" |
| 6 | 8 | "strings" |
| 7 | 9 | |
| @@ -74,7 +76,7 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { | ||
| 74 | 76 | } |
| 75 | 77 | case "enter": |
| 76 | 78 | if m.filteredKeys[m.selected].Key == "add_new" { |
| 77 | fmt.Println("Adding a new anime...") | |
| 79 | CurdOut("Adding a new anime...") | |
| 78 | 80 | m.filteredKeys[m.selected] = SelectionOption{"add_new", "0"} |
| 79 | 81 | return m, tea.Quit |
| 80 | 82 | } |
| @@ -168,8 +170,67 @@ func (m *Model) filterOptions() { | ||
| 168 | 170 | }) |
| 169 | 171 | } |
| 170 | 172 | |
| 173 | func RofiSelect(options map[string]string) (SelectionOption, error) { | |
| 174 | // Create a slice to store the options in the order we want | |
| 175 | var optionsList []string | |
| 176 | for _, value := range options { | |
| 177 | optionsList = append(optionsList, value) | |
| 178 | } | |
| 179 | ||
| 180 | // Sort the options alphabetically | |
| 181 | sort.Strings(optionsList) | |
| 182 | ||
| 183 | // Add "Add new anime" and "Quit" options | |
| 184 | optionsList = append(optionsList, "Add new anime", "Quit") | |
| 185 | ||
| 186 | // Join all options into a single string, separated by newlines | |
| 187 | optionsString := strings.Join(optionsList, "\n") | |
| 188 | ||
| 189 | // Prepare the Rofi command | |
| 190 | cmd := exec.Command("rofi", "-dmenu", "-i", "-p", "Select an anime") | |
| 191 | ||
| 192 | // Set up pipes for input and output | |
| 193 | cmd.Stdin = strings.NewReader(optionsString) | |
| 194 | var out bytes.Buffer | |
| 195 | cmd.Stdout = &out | |
| 196 | ||
| 197 | // Run the command | |
| 198 | err := cmd.Run() | |
| 199 | if err != nil { | |
| 200 | return SelectionOption{}, fmt.Errorf("failed to run Rofi: %v", err) | |
| 201 | } | |
| 202 | ||
| 203 | // Get the selected option | |
| 204 | selected := strings.TrimSpace(out.String()) | |
| 205 | ||
| 206 | // Handle special cases | |
| 207 | switch selected { | |
| 208 | case "": | |
| 209 | return SelectionOption{}, fmt.Errorf("no selection made") | |
| 210 | case "Add new anime": | |
| 211 | return SelectionOption{Label: "Add new anime", Key: "add_new"}, nil | |
| 212 | case "Quit": | |
| 213 | return SelectionOption{Label: "Quit", Key: "-1"}, nil | |
| 214 | } | |
| 215 | ||
| 216 | // Find the key for the selected value | |
| 217 | for key, value := range options { | |
| 218 | if value == selected { | |
| 219 | return SelectionOption{Label: value, Key: key}, nil | |
| 220 | } | |
| 221 | } | |
| 222 | ||
| 223 | // If we get here, the selected option wasn't found in the original map | |
| 224 | return SelectionOption{}, fmt.Errorf("selected option not found in original list") | |
| 225 | } | |
| 226 | ||
| 171 | 227 | // DynamicSelect displays a simple selection prompt without extra features |
| 172 | 228 | func DynamicSelect(options map[string]string) (SelectionOption, error) { |
| 229 | ||
| 230 | if GetGlobalConfig().RofiSelection { | |
| 231 | return RofiSelect(options) | |
| 232 | } | |
| 233 | ||
| 173 | 234 | model := &Model{ |
| 174 | 235 | options: options, |
| 175 | 236 | filteredKeys: make([]SelectionOption, 0), |