Documentation ¶
Index ¶
- type AppOptions
- type Builder
- func (b *Builder) AddMsgServiceCommands(cmd *cobra.Command, cmdDescriptor *autocliv1.ServiceCommandDescriptor) error
- func (b *Builder) AddQueryServiceCommands(cmd *cobra.Command, cmdDescriptor *autocliv1.ServiceCommandDescriptor) error
- func (b *Builder) BuildMsgCommand(ctx context.Context, appOptions AppOptions, ...) (*cobra.Command, error)
- func (b *Builder) BuildMsgMethodCommand(descriptor protoreflect.MethodDescriptor, options *autocliv1.RpcCommandOptions) (*cobra.Command, error)
- func (b *Builder) BuildQueryCommand(ctx context.Context, appOptions AppOptions, ...) (*cobra.Command, error)
- func (b *Builder) BuildQueryMethodCommand(ctx context.Context, descriptor protoreflect.MethodDescriptor, ...) (*cobra.Command, error)
- func (b *Builder) ValidateAndComplete() error
- type HasAutoCLIConfig
- type HasCustomQueryCommand
- type HasCustomTxCommand
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppOptions ¶
type AppOptions struct { depinject.In // Modules are the AppModule implementations for the modules in the app. Modules map[string]appmodule.AppModule // ModuleOptions are autocli options to be used for modules instead of what // is specified on the module's AppModule implementation. This allows an // app to override module options if they are either not provided by a // module or need to be improved. ModuleOptions map[string]*autocliv1.ModuleOptions `optional:"true"` AddressCodec address.Codec // AddressCodec is used to encode/decode account addresses. ValidatorAddressCodec address.ValidatorAddressCodec // ValidatorAddressCodec is used to encode/decode validator addresses. ConsensusAddressCodec address.ConsensusAddressCodec // ConsensusAddressCodec is used to encode/decode consensus addresses. // Cdc is the codec used for binary encoding/decoding of messages. Cdc codec.Codec // TxConfigOpts contains options for configuring transaction handling. TxConfigOpts authtx.ConfigOptions // contains filtered or unexported fields }
AppOptions are input options for an autocli enabled app. These options can be built via depinject based on an app config. Ex:
var autoCliOpts autocli.AppOptions err := depinject.Inject(appConfig, &encodingConfig.InterfaceRegistry, &autoCliOpts)
If depinject isn't used, options can be provided manually or extracted from modules and the address codec can be provided by the auth keeper. One method for extracting autocli options is via the github.com/cosmos/cosmos-sdk/runtime/services.ExtractAutoCLIOptions function.
func NewAppOptionsFromConfig ¶
func NewAppOptionsFromConfig( modulesConfig depinject.Config, moduleOptions map[string]*autocliv1.ModuleOptions, ) (AppOptions, error)
NewAppOptionsFromConfig returns AppOptions for an app based on the provided modulesConfig and moduleOptions. It returns an AppOptions instance usable for CLI parsing but not execution. For an execution usable AppOptions see ProvideAppOptions, which expects input to be filled by depinject.
func (AppOptions) EnhanceRootCommand ¶
func (appOptions AppOptions) EnhanceRootCommand(rootCmd *cobra.Command) error
EnhanceRootCommand enhances the provided root command with autocli AppOptions, only adding missing commands and doesn't override commands already in the root command. This allows for the graceful integration of autocli with existing app CLI commands where autocli simply automatically adds things that weren't manually provided. It does take into account custom commands provided by modules with the HasCustomQueryCommand or HasCustomTxCommand extension interface. Example Usage:
var autoCliOpts autocli.AppOptions err := depinject.Inject(appConfig, &autoCliOpts) if err != nil { panic(err) } rootCmd := initRootCmd() err = autoCliOpts.EnhanceRootCommand(rootCmd)
func (AppOptions) EnhanceRootCommandWithBuilder ¶
func (appOptions AppOptions) EnhanceRootCommandWithBuilder(rootCmd *cobra.Command, builder *Builder) error
type Builder ¶
type Builder struct { // flag.Builder embeds the flag builder and its options. flag.Builder // GetClientConn specifies how CLI commands will resolve a grpc.ClientConnInterface // from a given context. GetClientConn func(*cobra.Command) (grpc.ClientConnInterface, error) // AddQueryConnFlags and AddTxConnFlags are functions that add flags to query and transaction commands AddQueryConnFlags func(*cobra.Command) AddTxConnFlags func(*cobra.Command) Cdc codec.Codec EnabledSignModes []signing.SignMode }
Builder manages options for building CLI commands.
func (*Builder) AddMsgServiceCommands ¶
func (b *Builder) AddMsgServiceCommands(cmd *cobra.Command, cmdDescriptor *autocliv1.ServiceCommandDescriptor) error
AddMsgServiceCommands adds a sub-command to the provided command for each method in the specified service and returns the command. This can be used in order to add auto-generated commands to an existing command.
func (*Builder) AddQueryServiceCommands ¶
func (b *Builder) AddQueryServiceCommands(cmd *cobra.Command, cmdDescriptor *autocliv1.ServiceCommandDescriptor) error
AddQueryServiceCommands adds a sub-command to the provided command for each method in the specified service and returns the command. This can be used in order to add auto-generated commands to an existing command.
func (*Builder) BuildMsgCommand ¶
func (b *Builder) BuildMsgCommand(ctx context.Context, appOptions AppOptions, customCmds map[string]*cobra.Command) (*cobra.Command, error)
BuildMsgCommand builds the msg commands for all the provided modules. If a custom command is provided for a module, this is used instead of any automatically generated CLI commands. This allows apps to a fully dynamic client with a more customized experience if a binary with custom commands is downloaded.
func (*Builder) BuildMsgMethodCommand ¶
func (b *Builder) BuildMsgMethodCommand(descriptor protoreflect.MethodDescriptor, options *autocliv1.RpcCommandOptions) (*cobra.Command, error)
BuildMsgMethodCommand returns a command that outputs the JSON representation of the message.
func (*Builder) BuildQueryCommand ¶
func (b *Builder) BuildQueryCommand(ctx context.Context, appOptions AppOptions, customCmds map[string]*cobra.Command) (*cobra.Command, error)
BuildQueryCommand builds the query commands for all the provided modules. If a custom command is provided for a module, this is used instead of any automatically generated CLI commands. This allows apps to a fully dynamic client with a more customized experience if a binary with custom commands is downloaded.
func (*Builder) BuildQueryMethodCommand ¶
func (b *Builder) BuildQueryMethodCommand(ctx context.Context, descriptor protoreflect.MethodDescriptor, options *autocliv1.RpcCommandOptions) (*cobra.Command, error)
BuildQueryMethodCommand creates a gRPC query command for the given service method. This can be used to auto-generate just a single command for a single service rpc method.
func (*Builder) ValidateAndComplete ¶
ValidateAndComplete the builder fields. It returns an error if any of the required fields are missing.
type HasAutoCLIConfig ¶
type HasAutoCLIConfig interface { appmodule.AppModule // AutoCLIOptions are the autocli module options for this module. AutoCLIOptions() *autocliv1.ModuleOptions }
HasAutoCLIConfig is an AppModule extension interface for declaring autocli module options.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package flag defines functionality for automatically managing command line flags as well positional arguments that are based on protobuf message fields.
|
Package flag defines functionality for automatically managing command line flags as well positional arguments that are based on protobuf message fields. |