aboutsummaryrefslogtreecommitdiff
path: root/cmd/search.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-06-15 12:59:22 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-06-15 12:59:22 +0530
commitab3db8a4ca89293ce0928177e8845d622f13755f (patch)
treee5331856b39b43cfea422f806aa046b0925e92e4 /cmd/search.go
parent5eb7a3cd41826fccdc432d049dd85a31b4b56073 (diff)
added pretty template for TextInput
Diffstat (limited to 'cmd/search.go')
-rw-r--r--cmd/search.go18
1 files changed, 12 insertions, 6 deletions
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 <http://www.gnu.org/licenses/>.
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() {