From d6bf203e91f365bf07b62ae2383e6924e255cba8 Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Sun, 15 Oct 2023 23:59:52 +0200 Subject: [PATCH] Added q_cards args --- x/cardchain/client/cli/query_q_cards.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/x/cardchain/client/cli/query_q_cards.go b/x/cardchain/client/cli/query_q_cards.go index 143b3f14..80832f4e 100644 --- a/x/cardchain/client/cli/query_q_cards.go +++ b/x/cardchain/client/cli/query_q_cards.go @@ -1,6 +1,7 @@ package cli import ( + "fmt" "strconv" "github.com/DecentralCardGame/Cardchain/x/cardchain/types" @@ -13,11 +14,12 @@ var _ = strconv.Itoa(0) func CmdQCards() *cobra.Command { cmd := &cobra.Command{ - Use: "q-cards [owner] [status] [card-type] [classes] [sort-by] [name-contains] [keywords-contains] [notes-contains]", + Use: "q-cards [owner] [status] [card-type] [classes] [sort-by] [name-contains] [keywords-contains] [notes-contains] [only-startercard]", Short: "Query qCards", - Args: cobra.ExactArgs(8), + Args: cobra.ExactArgs(9), RunE: func(cmd *cobra.Command, args []string) (err error) { reqOwner := args[0] + var reqOnlyStarterCard bool var reqStatus types.QueryQCardsRequest_Status if args[1] == "" { reqStatus = types.QueryQCardsRequest_none @@ -31,6 +33,15 @@ func CmdQCards() *cobra.Command { reqKeywordsContains := args[6] reqNotesContains := args[7] + switch args[8]{ + case "yes": + reqOnlyStarterCard = true + case "no": + reqOnlyStarterCard = false + default: + return fmt.Errorf("arg 'only-startercard' has to be either yes or no but not %s", args[8]) + } + clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err @@ -48,6 +59,7 @@ func CmdQCards() *cobra.Command { NameContains: reqNameContains, KeywordsContains: reqKeywordsContains, NotesContains: reqNotesContains, + OnlyStarterCard: reqOnlyStarterCard, } res, err := queryClient.QCards(cmd.Context(), params)