Documentation ¶
Overview ¶
Package grpctl provides to build cobra commands from proto descriptors.
Index ¶
- func BuildCommand(cmd *cobra.Command, opts ...CommandOption) error
- func CommandFromFileDescriptor(cmd *cobra.Command, methods protoreflect.FileDescriptor) error
- func CommandFromFileDescriptors(cmd *cobra.Command, descriptors ...protoreflect.FileDescriptor) error
- func CommandFromMethodDescriptor(cmd *cobra.Command, method protoreflect.MethodDescriptor) error
- func CommandFromServiceDescriptor(cmd *cobra.Command, service protoreflect.ServiceDescriptor) error
- func ReflectionCommand() (*cobra.Command, error)
- func WithStdin(stdin io.Reader) func(cmd *cobra.Command) error
- type CommandOption
- func WithArgs(args []string) CommandOption
- func WithCompletion() CommandOption
- func WithContextDescriptorFunc(...) CommandOption
- func WithContextFunc(f func(context.Context, *cobra.Command) (context.Context, error)) CommandOption
- func WithFileDescriptors(descriptors ...protoreflect.FileDescriptor) CommandOption
- func WithReflection(args []string) CommandOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildCommand ¶
func BuildCommand(cmd *cobra.Command, opts ...CommandOption) error
BuildCommand builds a grpctl command from a list of GrpctlOption.
func CommandFromFileDescriptor ¶
func CommandFromFileDescriptor(cmd *cobra.Command, methods protoreflect.FileDescriptor) error
CommandFromFileDescriptor adds commands to cmd from a single FileDescriptor.
func CommandFromFileDescriptors ¶
func CommandFromFileDescriptors(cmd *cobra.Command, descriptors ...protoreflect.FileDescriptor) error
CommandFromFileDescriptors adds commands to cmd from FileDescriptors.
func CommandFromMethodDescriptor ¶
func CommandFromMethodDescriptor(cmd *cobra.Command, method protoreflect.MethodDescriptor) error
CommandFromMethodDescriptor adds commands to cmd from a MethodDescriptor. Commands added through this will have one level from the MethodDescriptors name.
func CommandFromServiceDescriptor ¶
func CommandFromServiceDescriptor(cmd *cobra.Command, service protoreflect.ServiceDescriptor) error
CommandFromServiceDescriptor adds commands to cmd from a ServiceDescriptor. Commands added through this will have two levels: the ServiceDescriptor name as level 1 commands And the MethodDescriptors as level 2 commands.
func ReflectionCommand ¶
ReflectionCommand returns the grpctl command that is used in the grpctl binary.
Types ¶
type CommandOption ¶
CommandOption are options to customize the grpctl cobra command.
func WithArgs ¶
func WithArgs(args []string) CommandOption
WithArgs will set the args of the command as args[1:].
func WithCompletion ¶
func WithCompletion() CommandOption
func WithContextDescriptorFunc ¶
func WithContextDescriptorFunc(f func(context.Context, *cobra.Command, protoreflect.MethodDescriptor) (context.Context, error)) CommandOption
WithContextDescriptorFunc will modify the context before the main command is run but not in the completion stage.
func WithContextFunc ¶
func WithContextFunc(f func(context.Context, *cobra.Command) (context.Context, error)) CommandOption
WithContextFunc will modify the context before the main command is run but not in the completion stage.
func WithFileDescriptors ¶
func WithFileDescriptors(descriptors ...protoreflect.FileDescriptor) CommandOption
WithContextFunc will add commands to the cobra command through the file descriptors provided.
func WithReflection ¶
func WithReflection(args []string) CommandOption
WithReflection will enable grpc reflection on the command. Use this as an alternative to WithFileDescriptors.