go-cyber/x/dmn/client/cli/query.go

package cli

import (
	"context"
	"fmt"

	"github.com/cosmos/cosmos-sdk/client/flags"
	sdk "github.com/cosmos/cosmos-sdk/types"
	"github.com/spf13/cobra"

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

	"github.com/cybercongress/go-cyber/v7/x/dmn/types"
)

func GetQueryCmd() *cobra.Command {
	queryCmd := &cobra.Command{
		Use:                        types.ModuleName,
		Short:                      fmt.Sprintf("Querying commands for the %s module", types.ModuleName),
		DisableFlagParsing:         true,
		SuggestionsMinimumDistance: 2,
		RunE:                       client.ValidateCmd,
	}

	queryCmd.AddCommand(
		GetCmdQueryParams(),
		GetCmdQueryThought(),
		GetCmdQueryThoughtStats(),
		GetCmdQueryThoughts(),
		GetCmdQueryThoughtsStats(),
	)

	return queryCmd
}

func GetCmdQueryParams() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "params",
		Args:  cobra.NoArgs,
		Short: "Query the current dmn module parameters information",
		RunE: func(cmd *cobra.Command, args []string) error {
			clientCtx, err := client.GetClientQueryContext(cmd)
			if err != nil {
				return err
			}
			queryClient := types.NewQueryClient(clientCtx)

			res, err := queryClient.Params(
				context.Background(),
				&types.QueryParamsRequest{},
			)
			if err != nil {
				return err
			}

			return clientCtx.PrintProto(res)
		},
	}

	flags.AddQueryFlagsToCmd(cmd)

	return cmd
}

func GetCmdQueryThought() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "thought [program] [name]",
		Short: "Query thought",
		Args:  cobra.ExactArgs(2),
		RunE: func(cmd *cobra.Command, args []string) error {
			clientCtx, err := client.GetClientQueryContext(cmd)
			if err != nil {
				return err
			}
			queryClient := types.NewQueryClient(clientCtx)

			program, err := sdk.AccAddressFromBech32(args[0])
			if err != nil {
				return err
			}

			res, err := queryClient.Thought(
				context.Background(),
				&types.QueryThoughtParamsRequest{
					Program: program.String(), Name: args[1],
				},
			)
			if err != nil {
				return err
			}

			return clientCtx.PrintProto(res)
		},
	}

	flags.AddQueryFlagsToCmd(cmd)

	return cmd
}

func GetCmdQueryThoughtStats() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "thought-stats [program] [name]",
		Short: "Query thought stats",
		Args:  cobra.ExactArgs(2),
		RunE: func(cmd *cobra.Command, args []string) error {
			clientCtx, err := client.GetClientQueryContext(cmd)
			if err != nil {
				return err
			}
			queryClient := types.NewQueryClient(clientCtx)

			program, err := sdk.AccAddressFromBech32(args[0])
			if err != nil {
				return err
			}

			res, err := queryClient.ThoughtStats(
				context.Background(),
				&types.QueryThoughtParamsRequest{
					Program: program.String(), Name: args[1],
				},
			)
			if err != nil {
				return err
			}

			return clientCtx.PrintProto(res)
		},
	}

	flags.AddQueryFlagsToCmd(cmd)

	return cmd
}

func GetCmdQueryThoughts() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "thoughts",
		Short: "Query all thoughts",
		Args:  cobra.ExactArgs(0),
		RunE: func(cmd *cobra.Command, args []string) error {
			clientCtx, err := client.GetClientQueryContext(cmd)
			if err != nil {
				return err
			}
			queryClient := types.NewQueryClient(clientCtx)

			res, err := queryClient.Thoughts(
				context.Background(),
				&types.QueryThoughtsRequest{},
			)
			if err != nil {
				return err
			}

			return clientCtx.PrintProto(res)
		},
	}

	flags.AddQueryFlagsToCmd(cmd)

	return cmd
}

func GetCmdQueryThoughtsStats() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "thoughts-stats",
		Short: "Query all thoughts stats",
		Args:  cobra.ExactArgs(0),
		RunE: func(cmd *cobra.Command, args []string) error {
			clientCtx, err := client.GetClientQueryContext(cmd)
			if err != nil {
				return err
			}
			queryClient := types.NewQueryClient(clientCtx)

			res, err := queryClient.ThoughtsStats(
				context.Background(),
				&types.QueryThoughtsStatsRequest{},
			)
			if err != nil {
				return err
			}

			return clientCtx.PrintProto(res)
		},
	}

	flags.AddQueryFlagsToCmd(cmd)

	return cmd
}

Synonyms

space-pussy/x/rank/client/cli/query.go
space-pussy/x/rank/client/rest/query.go
space-pussy/x/resources/client/rest/query.go
space-pussy/x/bandwidth/client/rest/query.go
space-pussy/x/graph/client/rest/query.go
space-pussy/x/bandwidth/client/cli/query.go
go-cyber/x/liquidity/client/cli/query.go
go-cyber/x/grid/client/cli/query.go
space-pussy/x/grid/client/cli/query.go
space-pussy/x/graph/client/cli/query.go
go-cyber/x/resources/client/cli/query.go
go-cyber/x/clock/client/cli/query.go
space-pussy/x/dmn/client/rest/query.go
space-pussy/x/dmn/client/cli/query.go
go-cyber/x/rank/client/cli/query.go
go-cyber/x/bandwidth/client/cli/query.go
go-cyber/x/tokenfactory/wasm/types/query.go
go-cyber/x/graph/client/cli/query.go
space-pussy/x/resources/client/cli/query.go
go-cyber/x/tokenfactory/client/cli/query.go
space-pussy/x/grid/client/rest/query.go

Neighbours