Skip to content

Commit

Permalink
add cli query
Browse files Browse the repository at this point in the history
  • Loading branch information
gusin13 committed May 2, 2023
1 parent 0e2074c commit 7824663
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions x/checkpointing/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func GetQueryCmd(queryRoute string) *cobra.Command {
}
cmd.AddCommand(CmdRawCheckpoint())
cmd.AddCommand(CmdRawCheckpointList())
cmd.AddCommand(CmdRawCheckpoints())

return cmd
}
Expand Down Expand Up @@ -97,3 +98,36 @@ func CmdRawCheckpoint() *cobra.Command {

return cmd
}

// CmdRawCheckpoints defines the cobra command to query the raw checkpoints
func CmdRawCheckpoints() *cobra.Command {
cmd := &cobra.Command{
Use: "raw-checkpoints",
Short: "retrieve the checkpoints",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx := client.GetClientContextFromCmd(cmd)

queryClient := types.NewQueryClient(clientCtx)

pageReq, err := client.ReadPageRequest(cmd.Flags())
if err != nil {
return err
}

res, err := queryClient.RawCheckpoints(context.Background(), &types.QueryRawCheckpointsRequest{
Pagination: pageReq,
})
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)
flags.AddPaginationFlagsToCmd(cmd, "raw-checkpoints")

return cmd
}

0 comments on commit 7824663

Please sign in to comment.