From d67758bdbeb162adadb6b19954e8e22cf04ed388 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Fri, 30 Sep 2022 15:10:58 +0530 Subject: reading both flags and config for searching commands --- cmd/list.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'cmd/list.go') diff --git a/cmd/list.go b/cmd/list.go index e6f7f8c..e4dbcf1 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -26,6 +26,7 @@ import ( // m "github.com/MikunoNaka/MAL2Go/v4/manga" "github.com/spf13/cobra" + "github.com/spf13/viper" ) // statusCmd represents the status command @@ -80,10 +81,13 @@ func init() { listCmd.Flags().StringP("status", "", "", "Status (leave blank for all)") listCmd.Flags().StringP("user", "", "@me", "User (@me or blank for self)") listCmd.Flags().StringP("sort", "", "list_score", "Sort the list") - listCmd.Flags().BoolP("include-nsfw", "", listIncludeNsfw, "Include NSFW results") + listCmd.Flags().BoolP("include-nsfw", "", false, "Include NSFW results") listCmd.Flags().BoolVarP(&mangaMode, "manga", "m", false, "Use manga mode") listCmd.Flags().StringVarP(&mal.Secret, "authentication-token", "t", "", "MyAnimeList authentication token to use (overrides system keyring if any)") - // TODO: implement below 2 flags - // listCmd.Flags().IntVarP(&mal.SearchLength, "list-length", "n", listLength, "Amount of list items to load (default: all)") - // listCmd.Flags().IntVarP(&mal.SearchOffset, "list-offset", "o", listOffset, "Offset for the list") + listCmd.Flags().IntVarP(&mal.SearchLength, "list-length", "n", 15, "Amount of list items to load (default: all)") + listCmd.Flags().IntVarP(&mal.SearchOffset, "list-offset", "o", 0, "Offset for the list") + + viper.BindPFlag("lists.list_offset", listCmd.Flags().Lookup("list-offset")) + viper.BindPFlag("lists.list_length", listCmd.Flags().Lookup("list-length")) + viper.BindPFlag("lists.include_nsfw_results", listCmd.Flags().Lookup("include-nsfw")) } -- cgit v1.2.3