aboutsummaryrefslogtreecommitdiff
path: root/cmd/list.go
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-09-30 15:10:58 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-09-30 15:10:58 +0530
commitd67758bdbeb162adadb6b19954e8e22cf04ed388 (patch)
tree1438369c1d980ebb041a04264da6d9006473e967 /cmd/list.go
parent37b5c5457d51b50af1dcadaf7c85be7e7349d682 (diff)
reading both flags and config for searching commands
Diffstat (limited to 'cmd/list.go')
-rw-r--r--cmd/list.go12
1 files changed, 8 insertions, 4 deletions
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"))
}