Documentation ¶
Overview ¶
Package flag defines functionality for automatically managing command line flags as well positional arguments that are based on protobuf message fields.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct { // TypeResolver specifies how protobuf types will be resolved. If it is // nil protoregistry.GlobalTypes will be used. TypeResolver interface { protoregistry.MessageTypeResolver protoregistry.ExtensionTypeResolver } // FileResolver specifies how protobuf file descriptors will be resolved. If it is // nil protoregistry.GlobalFiles will be used. FileResolver protodesc.Resolver // contains filtered or unexported fields }
Builder manages options for building pflag flags for protobuf messages.
func (*Builder) AddMessageFlags ¶
func (b *Builder) AddMessageFlags(ctx context.Context, flagSet *pflag.FlagSet, messageType protoreflect.MessageType, commandOptions *autocliv1.RpcCommandOptions) (*MessageBinder, error)
func (*Builder) DefineMessageFlagType ¶
func (b *Builder) DefineMessageFlagType(messageName protoreflect.FullName, flagType Type)
func (*Builder) DefineScalarFlagType ¶
type HasValue ¶
type HasValue interface { // Get gets the value of the protobuf value reference and returns that value // or an error. For composite protoreflect.Value types such as messages, // lists and maps, a mutable reference to the value of field obtained with // protoreflect.Message.NewField should be passed as the newFieldValue parameter. Get(newFieldValue protoreflect.Value) (protoreflect.Value, error) }
HasValue wraps a reference to a protobuf value.
type MessageBinder ¶
type MessageBinder struct { CobraArgs cobra.PositionalArgs // contains filtered or unexported fields }
MessageBinder binds multiple flags in a flag set to a protobuf message.
func (MessageBinder) Bind ¶
func (m MessageBinder) Bind(msg protoreflect.Message, positionalArgs []string) error
Bind binds the flag values to an existing protobuf message.
func (MessageBinder) BuildMessage ¶
func (m MessageBinder) BuildMessage(positionalArgs []string) (protoreflect.Message, error)
BuildMessage builds and returns a new message for the bound flags.
func (MessageBinder) Get ¶
func (m MessageBinder) Get(protoreflect.Value) (protoreflect.Value, error)
Get calls BuildMessage and wraps the result in a protoreflect.Value.
Click to show internal directories.
Click to hide internal directories.