github.com/loomnetwork/gamechain@v0.0.0-20200406110549-36c47eb97a92/cli/cmd/accept_match.go (about) 1 package cmd 2 3 import ( 4 "fmt" 5 "github.com/loomnetwork/gamechain/types/zb/zb_calls" 6 7 "github.com/loomnetwork/go-loom/auth" 8 "github.com/spf13/cobra" 9 ) 10 11 var acceptMatchCmdArgs struct { 12 userID string 13 matchID int64 14 } 15 16 var acceptMatchCmd = &cobra.Command{ 17 Use: "accept_match", 18 Short: "accept match", 19 RunE: func(cmd *cobra.Command, args []string) error { 20 signer := auth.NewEd25519Signer(commonTxObjs.privateKey) 21 var req = zb_calls.AcceptMatchRequest{ 22 UserId: acceptMatchCmdArgs.userID, 23 MatchId: acceptMatchCmdArgs.matchID, 24 } 25 var resp zb_calls.AcceptMatchResponse 26 27 _, err := commonTxObjs.contract.Call("AcceptMatch", &req, signer, &resp) 28 if err != nil { 29 return err 30 } 31 match := resp.Match 32 fmt.Printf("MatchID: %d\n", match.Id) 33 fmt.Printf("Status: %s\n", match.Status) 34 fmt.Printf("Topic: %v\n", match.Topics) 35 fmt.Printf("Players:\n") 36 for _, player := range match.PlayerStates { 37 fmt.Printf("\tPlayerID: %s\n", player.Id) 38 } 39 40 return nil 41 }, 42 } 43 44 func init() { 45 rootCmd.AddCommand(acceptMatchCmd) 46 47 acceptMatchCmd.Flags().StringVarP(&acceptMatchCmdArgs.userID, "userId", "u", "loom", "UserId of account") 48 acceptMatchCmd.Flags().Int64VarP(&acceptMatchCmdArgs.matchID, "matchId", "m", 0, "matchId") 49 }