From e82ed01a85e6dbaa838b8ee18b44f4d80a81390b Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sun, 17 Jul 2022 20:59:13 +0530 Subject: added flags for year, season and sort --- cmd/seasonals.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'cmd/seasonals.go') diff --git a/cmd/seasonals.go b/cmd/seasonals.go index 1e3eb20..7169488 100644 --- a/cmd/seasonals.go +++ b/cmd/seasonals.go @@ -39,9 +39,16 @@ var seasonalsCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { mal.Init() - currentSeason := util.GetCurrentSeason() + season := util.GetCurrentSeason() - res := mal.GetSeasonalAnime(currentSeason, "anime_score") + sort, _ := cmd.Flags().GetString("sort") + seasonInput, _ := cmd.Flags().GetString("season") + yearInput, _ := cmd.Flags().GetInt("year") + + if seasonInput != "" {season.Name = seasonInput} + if yearInput > 0 {season.Year = yearInput} + + res := mal.GetSeasonalAnime(season, sort) for _, i := range res { fmt.Println(i.Title) } @@ -57,4 +64,8 @@ func init() { seasonalsCmd.Flags().IntVarP(&mal.SearchLength, "results-length", "n", 10, "Amount of results to load") seasonalsCmd.Flags().BoolVarP(&mal.SearchNSFW, "include-nsfw", "", false, "Include NSFW-rated items in results") seasonalsCmd.Flags().IntVarP(&mal.SearchOffset, "results-offset", "o", 0, "Offset for the results") + + seasonalsCmd.Flags().StringP("sort", "", "anime_num_list_users", "sort") + seasonalsCmd.Flags().StringP("season", "", "", "") + seasonalsCmd.Flags().IntP("year", "", 0, "") } -- cgit v1.2.3