Documentation
¶
Index ¶
- Constants
- Variables
- func AddCommonProposalFlags(cmd *cobra.Command)
- func AddFlags(cmd *cobra.Command, desc FlagDesc)
- func AddQueryCmd[Q proto.Message, querier any](cmd *cobra.Command, newQueryClientFn func(grpc1.ClientConn) querier, ...)
- func AddTxCmd[M sdk.Msg](cmd *cobra.Command, f func() (*TxCliDesc, M))
- func BuildQueryCli[reqP proto.Message, querier any](desc *QueryDescriptor, newQueryClientFn func(grpc1.ClientConn) querier) *cobra.Command
- func BuildTxCli[M sdk.Msg](desc *TxCliDesc) *cobra.Command
- func FormatLongDesc(longString string, meta *LongMetadata) string
- func FormatLongDescDirect(longString string, moduleName string) string
- func GetParams[reqP proto.Message, querier any](moduleName string, newQueryClientFn func(grpc1.ClientConn) querier) *cobra.Command
- func GetProposalInfo(cmd *cobra.Command) (client.Context, string, string, sdk.Coins, bool, sdk.AccAddress, error)
- func IndexCmd(moduleName string) *cobra.Command
- func ParseCoin(arg string, fieldName string) (sdk.Coin, error)
- func ParseCoins(arg string, fieldName string) (sdk.Coins, error)
- func ParseDenom(arg string, fieldName string) (string, error)
- func ParseExpectedQueryFnName[reqP any]() string
- func ParseField(v reflect.Value, t reflect.Type, fieldIndex int, arg string, ...) (bool, error)
- func ParseFieldFromArg(fVal reflect.Value, fType reflect.StructField, arg string) error
- func ParseFieldFromFlag(fVal reflect.Value, fType reflect.StructField, flagAdvice FlagAdvice, ...) (bool, error)
- func ParseFieldsFromFlagsAndArgs[reqP any](flagAdvice FlagAdvice, flags *pflag.FlagSet, args []string) (reqP, error)
- func ParseFloat(arg string, fieldName string) (float64, error)
- func ParseHasPagination[reqP any]() bool
- func ParseInt(arg string, fieldName string) (int64, error)
- func ParseNumFields[reqP any]() int
- func ParseSdkDec(arg, fieldName string) (math.LegacyDec, error)
- func ParseSdkInt(arg string, fieldName string) (math.Int, error)
- func ParseStringTo2DArray(input string) ([][]uint64, error)
- func ParseUint(arg string, fieldName string) (uint64, error)
- func ParseUint64SliceToString(values []uint64) string
- func ParseUnixTime(arg string, fieldName string) (time.Time, error)
- func QueryIndexCmd(moduleName string) *cobra.Command
- func SimpleQueryCmd[reqP proto.Message, querier any](use string, short string, long string, moduleName string, ...) *cobra.Command
- func TxIndexCmd(moduleName string) *cobra.Command
- type CustomFieldParserFn
- type Descriptor
- type FieldReadLocation
- type FlagAdvice
- type FlagDesc
- type LongMetadata
- type QueryDescriptor
- type TxCliDesc
Constants ¶
const ( FlagIsExpedited = "is-expedited" FlagAuthority = "authority" )
Variables ¶
var DefaultGovAuthority = sdk.AccAddress(address.Module("gov"))
Functions ¶
func AddCommonProposalFlags ¶
func AddQueryCmd ¶
func AddQueryCmd[Q proto.Message, querier any](cmd *cobra.Command, newQueryClientFn func(grpc1.ClientConn) querier, f func() (*QueryDescriptor, Q))
func BuildQueryCli ¶
func BuildQueryCli[reqP proto.Message, querier any](desc *QueryDescriptor, newQueryClientFn func(grpc1.ClientConn) querier) *cobra.Command
func FormatLongDesc ¶
func FormatLongDesc(longString string, meta *LongMetadata) string
func FormatLongDescDirect ¶
func GetProposalInfo ¶
func ParseCoins ¶
TODO: Make this able to read from some local alias file for denoms.
func ParseField ¶
func ParseField(v reflect.Value, t reflect.Type, fieldIndex int, arg string, flagAdvice FlagAdvice, flags *pflag.FlagSet) (bool, error)
ParseField parses field #fieldIndex from either an arg or a flag. Returns true if it was parsed from an argument. Returns error if there was an issue in parsing this field.
func ParseFieldFromArg ¶
func ParseFieldFromFlag ¶
func ParseFieldFromFlag(fVal reflect.Value, fType reflect.StructField, flagAdvice FlagAdvice, flags *pflag.FlagSet) (bool, error)
ParseFieldFromFlag attempts to parses the value of a field in a struct from a flag. The field is identified by the provided `reflect.StructField`. The flag advice and `pflag.FlagSet` are used to determine the flag to parse the field from. If the field corresponds to a value from a flag, true is returned. Otherwise, `false` is returned. In the true case, the parsed value is set on the provided `reflect.Value`. An error is returned if there is an issue parsing the field from the flag.
func ParseFieldsFromFlagsAndArgs ¶
func ParseFieldsFromFlagsAndArgs[reqP any](flagAdvice FlagAdvice, flags *pflag.FlagSet, args []string) (reqP, error)
Parses arguments 1-1 from args makes an exception, where it allows Pagination to come from flags.
func ParseHasPagination ¶
func ParseNumFields ¶
func ParseSdkInt ¶
TODO: This really shouldn't be getting used in the CLI, its misdesign on the CLI ux
func ParseStringTo2DArray ¶
func ParseUint64SliceToString ¶
ParseUint64SliceToString converts a slice of uint64 values into a string. Each uint64 value in the slice is converted to a string using base 10. The resulting strings are then joined together with a comma separator. The resulting string is returned.
func QueryIndexCmd ¶
func SimpleQueryCmd ¶
func SimpleQueryCmd[reqP proto.Message, querier any](use string, short string, long string, moduleName string, newQueryClientFn func(grpc1.ClientConn) querier, ) *cobra.Command
SimpleQueryCmd builds a query, for the common, simple case. It detects that the querier function name is the same as the ProtoMessage name, with just the "Query" and "Request" args chopped off. It expects all proto fields to appear as arguments, in order.
func TxIndexCmd ¶
Types ¶
type CustomFieldParserFn ¶
type CustomFieldParserFn = func(arg string, flags *pflag.FlagSet) (valueToSet any, usedArg FieldReadLocation, err error)
CustomFieldParser function.
func FlagOnlyParser ¶
func FlagOnlyParser[v any](f func(fs *pflag.FlagSet) (v, error)) CustomFieldParserFn
type Descriptor ¶
type FieldReadLocation ¶
type FieldReadLocation = bool
const ( UsedArg FieldReadLocation = true UsedFlag FieldReadLocation = false )
type FlagAdvice ¶
type FlagAdvice struct { HasPagination bool // Map of FieldName -> FlagName CustomFlagOverrides map[string]string CustomFieldParsers map[string]CustomFieldParserFn // Tx sender value IsTx bool TxSenderFieldName string FromValue string }
func (FlagAdvice) Sanitize ¶
func (f FlagAdvice) Sanitize() FlagAdvice
type LongMetadata ¶
type LongMetadata struct { BinaryName string CommandPrefix string Short string // Newline Example: ExampleHeader string }
func NewLongMetadata ¶
func NewLongMetadata(moduleName string) *LongMetadata
func (*LongMetadata) WithShort ¶
func (m *LongMetadata) WithShort(short string) *LongMetadata
type QueryDescriptor ¶
type QueryDescriptor struct { Use string Short string Long string HasPagination bool QueryFnName string Flags FlagDesc // Map of FieldName -> FlagName CustomFlagOverrides map[string]string // Map of FieldName -> CustomParseFn CustomFieldParsers map[string]CustomFieldParserFn ParseQuery func(args []string, flags *pflag.FlagSet) (proto.Message, error) ModuleName string // contains filtered or unexported fields }
func (*QueryDescriptor) AttachToUse ¶
func (desc *QueryDescriptor) AttachToUse(str string)
Implement Descriptor interface
func (*QueryDescriptor) FormatLong ¶
func (desc *QueryDescriptor) FormatLong(moduleName string)
func (QueryDescriptor) GetCustomFlagOverrides ¶
func (desc QueryDescriptor) GetCustomFlagOverrides() map[string]string
Implement Descriptor interface
type TxCliDesc ¶
type TxCliDesc struct { Use string Short string Long string Example string NumArgs int // Contract: len(args) = NumArgs ParseAndBuildMsg func(clientCtx client.Context, args []string, flags *pflag.FlagSet) (sdk.Msg, error) TxSignerFieldName string Flags FlagDesc // Map of FieldName -> FlagName CustomFlagOverrides map[string]string // Map of FieldName -> CustomParseFn CustomFieldParsers map[string]CustomFieldParserFn }
func (*TxCliDesc) AttachToUse ¶
Implement Descriptor interface
func (TxCliDesc) BuildCommandCustomFn ¶
Creates a new cobra command given the description. Its up to then caller to add CLI flags, aside from `flags.AddTxFlagsToCmd(cmd)`
func (TxCliDesc) GetCustomFlagOverrides ¶
Implement Descriptor interface