github.com/loomnetwork/gamechain@v0.0.0-20200406110549-36c47eb97a92/cli/cmd/list_card.go (about) 1 package cmd 2 3 import ( 4 "fmt" 5 "github.com/loomnetwork/gamechain/tools/battleground_utility" 6 "github.com/loomnetwork/gamechain/types/zb/zb_calls" 7 8 "github.com/loomnetwork/go-loom" 9 "github.com/loomnetwork/go-loom/auth" 10 "github.com/spf13/cobra" 11 ) 12 13 var listCardCmdArgs struct { 14 version string 15 } 16 17 var listCardCmd = &cobra.Command{ 18 Use: "list_card_library", 19 Short: "list card_library", 20 RunE: func(cmd *cobra.Command, args []string) error { 21 22 if listCardCmdArgs.version == "" { 23 return fmt.Errorf("version not specified") 24 } 25 26 signer := auth.NewEd25519Signer(commonTxObjs.privateKey) 27 callerAddr := loom.Address{ 28 ChainID: commonTxObjs.rpcClient.GetChainID(), 29 Local: loom.LocalAddressFromPublicKey(signer.PublicKey()), 30 } 31 32 req := zb_calls.ListCardLibraryRequest{ 33 Version: listCardCmdArgs.version, 34 } 35 result := zb_calls.ListCardLibraryResponse{} 36 37 _, err := commonTxObjs.contract.StaticCall("ListCardLibrary", &req, callerAddr, &result) 38 if err != nil { 39 return err 40 } 41 42 return battleground_utility.PrintProtoMessageAsJsonToStdout(&result) 43 }, 44 } 45 46 func init() { 47 rootCmd.AddCommand(listCardCmd) 48 listCardCmd.Flags().StringVarP(&listCardCmdArgs.version, "version", "v", "", "Version") 49 50 _ = listCardCmd.MarkFlagRequired("version") 51 }