From ab3db8a4ca89293ce0928177e8845d622f13755f Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Wed, 15 Jun 2022 12:59:22 +0530 Subject: added pretty template for TextInput --- cmd/search.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'cmd/search.go') diff --git a/cmd/search.go b/cmd/search.go index 28be82c..453f13d 100644 --- a/cmd/search.go +++ b/cmd/search.go @@ -19,10 +19,10 @@ along with this program. If not, see . package cmd import ( + "strings" "github.com/spf13/cobra" "github.com/MikunoNaka/macli/ui" - "strings" - "fmt" + "github.com/MikunoNaka/macli/mal" ) var searchCmd = &cobra.Command { @@ -32,6 +32,7 @@ var searchCmd = &cobra.Command { -- help/description to be added later `, Run: func(cmd *cobra.Command, args []string) { + mal.Init() // needs to be manually called else it won't let you login // read searchInput from command searchInput := strings.Join(args, " ") mangaMode, _ := cmd.Flags().GetBool("manga") @@ -45,22 +46,27 @@ var searchCmd = &cobra.Command { } func searchManga(searchInput string) { + mangaIsAdded := false if searchInput == "" { - searchInput = ui.TextInput("Search Manga:", "Search can't be blank.") + searchInput = ui.TextInput("Search Manga: ", "Search can't be blank.") + } + manga := ui.MangaSearch("Select Manga:", searchInput) + if manga.MyListStatus.Status != "" { + mangaIsAdded = true } - fmt.Printf("You typed in \"%s\" but macli doesn't search manga yet.\n", searchInput) + ui.MangaActionMenu(mangaIsAdded)(manga) } func searchAnime(searchInput string) { animeIsAdded := false if searchInput == "" { - searchInput = ui.TextInput("Search Anime", "Search can't be blank.") + searchInput = ui.TextInput("Search Anime: ", "Search can't be blank.") } anime := ui.AnimeSearch("Select Anime:", searchInput) if anime.MyListStatus.Status != "" { animeIsAdded = true } - ui.ActionMenu(animeIsAdded)(anime) + ui.AnimeActionMenu(animeIsAdded)(anime) } func init() { -- cgit v1.2.3