aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-10-02 20:46:50 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-10-02 20:46:50 +0530
commit8fb49796e37d2bf955d8ffa521f6bcda4f36b766 (patch)
treee0728f19a33c2f8f71767472c10767548ce99e94 /ui
parente0da6a5205169f34671addd533739b6242d5eff3 (diff)
Automatically select nth search result with --auto-select flag
Diffstat (limited to 'ui')
-rw-r--r--ui/search.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/ui/search.go b/ui/search.go
index 60089f3..a8e8f51 100644
--- a/ui/search.go
+++ b/ui/search.go
@@ -40,6 +40,15 @@ var AnimeSearchFields []string = []string {
// only search animes probably only now
func AnimeSearch(label, searchString string) a.Anime {
animes := mal.SearchAnime(searchString, AnimeSearchFields)
+ // don't show selection prompt if --auto-select is passed
+ if mal.AutoSel > 0 {
+ if len(animes) > 0 {
+ return animes[0]
+ } else {
+ fmt.Println("Error: Empty response from MyAnimeList while searching for anime.")
+ os.Exit(1)
+ }
+ }
for i, anime := range animes {
animes[i].DurationSeconds = anime.DurationSeconds / 60
@@ -148,6 +157,15 @@ var MangaSearchFields []string = []string {
func MangaSearch(label, searchString string) m.Manga {
mangas := mal.SearchManga(searchString, MangaSearchFields)
+ // don't show selection prompt if --auto-select is passed
+ if mal.AutoSel > 0 {
+ if len(mangas) > 0 {
+ return mangas[0]
+ } else {
+ fmt.Println("Error: Empty response from MyAnimeList while searching for manga.")
+ os.Exit(1)
+ }
+ }
for i, manga := range mangas {
/* I cant find a way to add functions to the details template