Skip to content

Commit

Permalink
feat(logic): introduce "limit" flag to command "ask"
Browse files Browse the repository at this point in the history
  • Loading branch information
ccamel committed Apr 3, 2024
1 parent c335b0f commit 58b4c45
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion x/logic/client/cli/query_ask.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@ import (

"github.com/spf13/cobra"

sdkmath "cosmossdk.io/math"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/version"

"github.com/okp4/okp4d/v7/x/logic/types"
)

var program string
var (
program string
limit uint64
)

func CmdQueryAsk() *cobra.Command {
cmd := &cobra.Command{
Expand All @@ -33,9 +38,11 @@ func CmdQueryAsk() *cobra.Command {
query := args[0]
queryClient := types.NewQueryServiceClient(clientCtx)

limit := sdkmath.NewUint(limit)
res, err := queryClient.Ask(context.Background(), &types.QueryServiceAskRequest{
Program: program,
Query: query,
Limit: &limit,
})
if err != nil {
return
Expand All @@ -50,6 +57,13 @@ func CmdQueryAsk() *cobra.Command {
"program",
"",
`reads the program from the given string.`)
//nolint:lll
cmd.Flags().Uint64Var(
&limit,
"limit",
1,
`limit the maximum number of solutions to return.
This parameter is constrained by the 'max_result_count' setting in the module configuration, which specifies the maximum number of results that can be requested per query.`)

flags.AddQueryFlagsToCmd(cmd)

Expand Down

0 comments on commit 58b4c45

Please sign in to comment.