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(moduleOptions map[string]*autocliv1.ModuleOptions, ...) (*cobra.Command, error)
- func (b *Builder) BuildMsgMethodCommand(descriptor protoreflect.MethodDescriptor, options *autocliv1.RpcCommandOptions) (*cobra.Command, error)
- func (b *Builder) BuildQueryCommand(moduleOptions map[string]*autocliv1.ModuleOptions, ...) (*cobra.Command, error)
- func (b *Builder) BuildQueryMethodCommand(descriptor protoreflect.MethodDescriptor, options *autocliv1.RpcCommandOptions) (*cobra.Command, 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"` }
AppOptions are autocli options for an app. These options can be built via depinject based on an app config. Ex: 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. One method for extracting autocli options is via the github.com/verzth/cosmos-sdk/runtime/services.ExtractAutoCLIOptions function.
func (AppOptions) EnhanceRootCommand ¶
func (appOptions AppOptions) EnhanceRootCommand(rootCmd *cobra.Command) error
EnhanceRootCommand enhances the provided root command with autocli AppOptions, only adding missing query 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 query commands provided by modules with the HasCustomQueryCommand 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 func(*cobra.Command) AddTxConnFlags func(*cobra.Command) }
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(moduleOptions map[string]*autocliv1.ModuleOptions, 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)
func (*Builder) BuildQueryCommand ¶
func (b *Builder) BuildQueryCommand(moduleOptions map[string]*autocliv1.ModuleOptions, 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(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.
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. |