types

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package types provides implementations for converting protobuf field types to pflag.Value types. This package enables command-line flag generation for protobuf messages by implementing the pflag.Value interface for various protobuf field types.

Package types provides implementations for converting protobuf field types to pflag.Value types. This package enables command-line flag generation for protobuf messages by implementing the pflag.Value interface for various protobuf field types.

Package types provides implementations for converting protobuf field types to pflag.Value types. This package enables command-line flag generation for protobuf messages by implementing the pflag.Value interface for various protobuf field types.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesHexSlice

func BytesHexSlice[T []*wrapperspb.BytesValue | [][]byte](v *T) pflag.Value

func BytesSlice

func BytesSlice[T []*wrapperspb.BytesValue | [][]byte](v *T) pflag.Value

Types

type BoolSliceValue

type BoolSliceValue struct {
	// contains filtered or unexported fields
}

func BoolSlice

func BoolSlice(v *[]*wrapperspb.BoolValue) *BoolSliceValue

func (*BoolSliceValue) Set

func (s *BoolSliceValue) Set(val string) error

Set converts, and assigns, the comma-separated boolean argument string representation as the []*wrapperspb.BoolValue value of this flag. If Set is called on a flag that already has a []*wrapperspb.BoolValue assigned, the newly converted values will be appended.

func (*BoolSliceValue) String

func (s *BoolSliceValue) String() string

String defines a "native" format for this boolean slice flag value.

func (*BoolSliceValue) Type

func (s *BoolSliceValue) Type() string

Type returns a string that uniquely represents this flag's type.

type BoolValue

type BoolValue wrapperspb.BoolValue

func Bool

func Bool(v *wrapperspb.BoolValue) *BoolValue

func (*BoolValue) Set

func (b *BoolValue) Set(s string) error

func (*BoolValue) String

func (b *BoolValue) String() string

func (*BoolValue) Type

func (b *BoolValue) Type() string

type BytesHexNativeSliceValue

type BytesHexNativeSliceValue struct {
	// contains filtered or unexported fields
}

func (*BytesHexNativeSliceValue) Append

func (s *BytesHexNativeSliceValue) Append(val string) error

func (*BytesHexNativeSliceValue) GetSlice

func (s *BytesHexNativeSliceValue) GetSlice() []string

func (*BytesHexNativeSliceValue) Replace

func (s *BytesHexNativeSliceValue) Replace(val []string) error

func (*BytesHexNativeSliceValue) Set

func (*BytesHexNativeSliceValue) String

func (s *BytesHexNativeSliceValue) String() string

String defines a "native" format for this bytes slice flag value.

func (*BytesHexNativeSliceValue) Type

func (s *BytesHexNativeSliceValue) Type() string

Type returns a string that uniquely represents this flag's type.

type BytesHexSliceValue

type BytesHexSliceValue struct {
	// contains filtered or unexported fields
}

func (*BytesHexSliceValue) Append

func (s *BytesHexSliceValue) Append(val string) error

func (*BytesHexSliceValue) GetSlice

func (s *BytesHexSliceValue) GetSlice() []string

func (*BytesHexSliceValue) Replace

func (s *BytesHexSliceValue) Replace(val []string) error

func (*BytesHexSliceValue) Set

func (s *BytesHexSliceValue) Set(val string) error

func (*BytesHexSliceValue) String

func (s *BytesHexSliceValue) String() string

String defines a "native" format for this hexadecimal slice flag value.

func (*BytesHexSliceValue) Type

func (s *BytesHexSliceValue) Type() string

Type returns a string that uniquely represents this flag's type.

type BytesHexValue

type BytesHexValue wrapperspb.BytesValue

func BytesHex

func BytesHex(v *wrapperspb.BytesValue) *BytesHexValue

func (*BytesHexValue) Set

func (b *BytesHexValue) Set(value string) error

func (*BytesHexValue) String

func (b *BytesHexValue) String() string

func (*BytesHexValue) Type

func (b *BytesHexValue) Type() string

type BytesSliceValue

type BytesSliceValue struct {
	// contains filtered or unexported fields
}

func (*BytesSliceValue) Append

func (s *BytesSliceValue) Append(val string) error

func (*BytesSliceValue) GetSlice

func (s *BytesSliceValue) GetSlice() []string

func (*BytesSliceValue) Replace

func (s *BytesSliceValue) Replace(val []string) error

func (*BytesSliceValue) Set

func (s *BytesSliceValue) Set(val string) error

func (*BytesSliceValue) String

func (s *BytesSliceValue) String() string

String defines a "native" format for this bytes slice flag value.

func (*BytesSliceValue) Type

func (s *BytesSliceValue) Type() string

Type returns a string that uniquely represents this flag's type.

type BytesValue

type BytesValue wrapperspb.BytesValue

func Bytes

func Bytes(v *wrapperspb.BytesValue) *BytesValue

func (*BytesValue) Set

func (b *BytesValue) Set(value string) error

func (*BytesValue) String

func (b *BytesValue) String() string

func (*BytesValue) Type

func (b *BytesValue) Type() string

type DoubleSliceValue

type DoubleSliceValue struct {
	// contains filtered or unexported fields
}

func DoubleSlice

func DoubleSlice(v *[]*wrapperspb.DoubleValue) *DoubleSliceValue

func (*DoubleSliceValue) Set

func (s *DoubleSliceValue) Set(val string) error

Set converts, and assigns, the comma-separated double argument string representation as the []*wrapperspb.DoubleValue value of this flag. If Set is called on a flag that already has a []*wrapperspb.DoubleValue assigned, the newly converted values will be appended.

func (*DoubleSliceValue) String

func (s *DoubleSliceValue) String() string

String defines a "native" format for this double slice flag value.

func (*DoubleSliceValue) Type

func (s *DoubleSliceValue) Type() string

Type returns a string that uniquely represents this flag's type.

type DoubleValue

type DoubleValue wrapperspb.DoubleValue

func Double

func (*DoubleValue) Set

func (d *DoubleValue) Set(s string) error

func (*DoubleValue) String

func (d *DoubleValue) String() string

func (*DoubleValue) Type

func (d *DoubleValue) Type() string

type DurationSliceValue

type DurationSliceValue struct {
	// contains filtered or unexported fields
}

func DurationSlice

func DurationSlice(v *[]*durationpb.Duration) *DurationSliceValue

func (*DurationSliceValue) Append

func (s *DurationSliceValue) Append(val string) error

func (*DurationSliceValue) GetSlice

func (s *DurationSliceValue) GetSlice() []string

func (*DurationSliceValue) Replace

func (s *DurationSliceValue) Replace(val []string) error

func (*DurationSliceValue) Set

func (s *DurationSliceValue) Set(val string) error

func (*DurationSliceValue) String

func (s *DurationSliceValue) String() string

String defines a "native" format for this duration slice flag value.

func (*DurationSliceValue) Type

func (s *DurationSliceValue) Type() string

Type returns a string that uniquely represents this flag's type.

type DurationValue

type DurationValue durationpb.Duration

func Duration

func Duration(value *durationpb.Duration) *DurationValue

func (*DurationValue) Set

func (d *DurationValue) Set(s string) error

func (*DurationValue) String

func (d *DurationValue) String() string

func (*DurationValue) Type

func (d *DurationValue) Type() string

type EnumSliceValue

type EnumSliceValue struct {
	// contains filtered or unexported fields
}

func EnumSlice

func EnumSlice(arrPtr any) *EnumSliceValue

func (*EnumSliceValue) Append

func (s *EnumSliceValue) Append(val string) error

func (*EnumSliceValue) GetSlice

func (s *EnumSliceValue) GetSlice() []string

func (*EnumSliceValue) Replace

func (s *EnumSliceValue) Replace(val []string) error

func (*EnumSliceValue) Set

func (s *EnumSliceValue) Set(val string) error

func (*EnumSliceValue) String

func (s *EnumSliceValue) String() string

String defines a "native" format for this enum slice flag value.

func (*EnumSliceValue) Type

func (s *EnumSliceValue) Type() string

Type returns a string that uniquely represents this flag's type.

type EnumValue

type EnumValue struct {
	// contains filtered or unexported fields
}

EnumValue implements the pflag.Value interface for protobuf enum types. It provides string representation and parsing capabilities for enum values, allowing them to be used as command-line flags.

func Enum

func Enum(wrap protoreflect.Enum) *EnumValue

Enum creates a new EnumValue wrapper for the given protobuf enum. It extracts the allowed enum values from the enum descriptor and returns an EnumValue that can be used as a pflag.Value.

func (*EnumValue) Set

func (e *EnumValue) Set(s string) error

Set parses the string and updates the enum value accordingly. It validates that the string corresponds to a valid enum value name. Returns an error if the string is not a valid enum value or if the enum cannot be set.

func (*EnumValue) String

func (e *EnumValue) String() string

String returns the string representation of the enum value. If the enum value has a corresponding name in the descriptors, it returns the name. Otherwise, it returns the numeric value as a string.

func (*EnumValue) Type

func (e *EnumValue) Type() string

Type returns the data type name of the enum value. This method implements the pflag.Value interface.

type FloatSliceValue

type FloatSliceValue struct {
	// contains filtered or unexported fields
}

func FloatSlice

func FloatSlice(v *[]*wrapperspb.FloatValue) *FloatSliceValue

func (*FloatSliceValue) Set

func (s *FloatSliceValue) Set(val string) error

Set converts, and assigns, the comma-separated float argument string representation as the []*wrapperspb.FloatValue value of this flag. If Set is called on a flag that already has a []*wrapperspb.FloatValue assigned, the newly converted values will be appended.

func (*FloatSliceValue) String

func (s *FloatSliceValue) String() string

String defines a "native" format for this float slice flag value.

func (*FloatSliceValue) Type

func (s *FloatSliceValue) Type() string

Type returns a string that uniquely represents this flag's type.

type FloatValue

type FloatValue wrapperspb.FloatValue

func Float

func Float(v *wrapperspb.FloatValue) *FloatValue

func (*FloatValue) Set

func (b *FloatValue) Set(s string) error

func (*FloatValue) String

func (b *FloatValue) String() string

func (*FloatValue) Type

func (b *FloatValue) Type() string

type Int32SliceValue

type Int32SliceValue struct {
	// contains filtered or unexported fields
}

func Int32Slice

func Int32Slice(v *[]*wrapperspb.Int32Value) *Int32SliceValue

func (*Int32SliceValue) Set

func (s *Int32SliceValue) Set(val string) error

Set converts, and assigns, the comma-separated int32 argument string representation as the []*wrapperspb.Int32Value value of this flag. If Set is called on a flag that already has a []*wrapperspb.Int32Value assigned, the newly converted values will be appended.

func (*Int32SliceValue) String

func (s *Int32SliceValue) String() string

String defines a "native" format for this int32 slice flag value.

func (*Int32SliceValue) Type

func (s *Int32SliceValue) Type() string

Type returns a string that uniquely represents this flag's type.

type Int32Value

type Int32Value wrapperspb.Int32Value

func Int32

func Int32(v *wrapperspb.Int32Value) *Int32Value

func (*Int32Value) Set

func (i *Int32Value) Set(s string) error

func (*Int32Value) String

func (i *Int32Value) String() string

func (*Int32Value) Type

func (i *Int32Value) Type() string

type Int64SliceValue

type Int64SliceValue struct {
	// contains filtered or unexported fields
}

func Int64Slice

func Int64Slice(v *[]*wrapperspb.Int64Value) *Int64SliceValue

func (*Int64SliceValue) Set

func (s *Int64SliceValue) Set(val string) error

func (*Int64SliceValue) String

func (s *Int64SliceValue) String() string

String defines a "native" format for this int64 slice flag value.

func (*Int64SliceValue) Type

func (s *Int64SliceValue) Type() string

Type returns a string that uniquely represents this flag's type.

type Int64Value

type Int64Value wrapperspb.Int64Value

func Int64

func Int64(v *wrapperspb.Int64Value) *Int64Value

func (*Int64Value) Set

func (i *Int64Value) Set(s string) error

func (*Int64Value) String

func (i *Int64Value) String() string

func (*Int64Value) Type

func (i *Int64Value) Type() string

type JSONValue

type JSONValue struct {
	// contains filtered or unexported fields
}

JSONValue implements the pflag.Value interface for protobuf map and struct types. It provides JSON string representation and parsing capabilities for complex types, allowing them to be used as command-line flags.

func JSON

func JSON(v interface{}) *JSONValue

JSON creates a new JSONValue for the given protobuf message pointer.

func (*JSONValue) Set

func (j *JSONValue) Set(value string) error

Set parses a JSON string and sets the map/struct value.

func (*JSONValue) String

func (j *JSONValue) String() string

String returns the JSON string representation of the map/struct value.

func (*JSONValue) Type

func (j *JSONValue) Type() string

Type returns the type name for help text.

type NativeBytesSliceValue

type NativeBytesSliceValue struct {
	// contains filtered or unexported fields
}

NativeBytesSliceValue is a pflag.Value implementation for handling native [][]byte fields. It supports base64 encoding for command-line flag parsing.

func (*NativeBytesSliceValue) Append

func (s *NativeBytesSliceValue) Append(val string) error

func (*NativeBytesSliceValue) GetSlice

func (s *NativeBytesSliceValue) GetSlice() []string

func (*NativeBytesSliceValue) Replace

func (s *NativeBytesSliceValue) Replace(val []string) error

func (*NativeBytesSliceValue) Set

func (s *NativeBytesSliceValue) Set(val string) error

func (*NativeBytesSliceValue) String

func (s *NativeBytesSliceValue) String() string

String defines a "native" format for this bytes slice flag value.

func (*NativeBytesSliceValue) Type

func (s *NativeBytesSliceValue) Type() string

Type returns a string that uniquely represents this flag's type.

type StringSliceValue

type StringSliceValue struct {
	// contains filtered or unexported fields
}

func StringSlice

func StringSlice(v *[]*wrapperspb.StringValue) *StringSliceValue

func (*StringSliceValue) Append

func (s *StringSliceValue) Append(val string) error

func (*StringSliceValue) GetSlice

func (s *StringSliceValue) GetSlice() []string

func (*StringSliceValue) Replace

func (s *StringSliceValue) Replace(val []string) error

func (*StringSliceValue) Set

func (s *StringSliceValue) Set(val string) error

func (*StringSliceValue) String

func (s *StringSliceValue) String() string

String defines a "native" format for this string slice flag value.

func (*StringSliceValue) Type

func (s *StringSliceValue) Type() string

Type returns a string that uniquely represents this flag's type.

type StringToInt32Map

type StringToInt32Map struct {
	// contains filtered or unexported fields
}

StringToInt32Map implements pflag.Value for map[string]int32

func StringToInt32

func StringToInt32(v interface{}) *StringToInt32Map

StringToInt32 Constructor functions

func (*StringToInt32Map) Set

func (s *StringToInt32Map) Set(val string) error

Set parses a comma-separated list of key=value pairs

func (*StringToInt32Map) String

func (s *StringToInt32Map) String() string

String returns the string representation of the map

func (*StringToInt32Map) Type

func (s *StringToInt32Map) Type() string

Type returns the type name for help text

type StringToUint32Map

type StringToUint32Map struct {
	// contains filtered or unexported fields
}

StringToUint32Map implements pflag.Value for map[string]uint32

func StringToUint32

func StringToUint32(v interface{}) *StringToUint32Map

func (*StringToUint32Map) Set

func (s *StringToUint32Map) Set(val string) error

Set parses a comma-separated list of key=value pairs

func (*StringToUint32Map) String

func (s *StringToUint32Map) String() string

String returns the string representation of the map

func (*StringToUint32Map) Type

func (s *StringToUint32Map) Type() string

Type returns the type name for help text

type StringToUint64Map

type StringToUint64Map struct {
	// contains filtered or unexported fields
}

StringToUint64Map implements pflag.Value for map[string]uint64

func StringToUint64

func StringToUint64(v interface{}) *StringToUint64Map

func (*StringToUint64Map) Set

func (s *StringToUint64Map) Set(val string) error

Set parses a comma-separated list of key=value pairs

func (*StringToUint64Map) String

func (s *StringToUint64Map) String() string

String returns the string representation of the map

func (*StringToUint64Map) Type

func (s *StringToUint64Map) Type() string

Type returns the type name for help text

type StringValue

type StringValue wrapperspb.StringValue

func String

func (*StringValue) Set

func (s *StringValue) Set(value string) error

func (*StringValue) String

func (s *StringValue) String() string

func (*StringValue) Type

func (s *StringValue) Type() string

type TimestampSliceValue

type TimestampSliceValue struct {
	// contains filtered or unexported fields
}

func TimestampSlice

func TimestampSlice(v *[]*timestamppb.Timestamp, formats []string) *TimestampSliceValue

func (*TimestampSliceValue) Append

func (t *TimestampSliceValue) Append(val string) error

func (*TimestampSliceValue) GetSlice

func (t *TimestampSliceValue) GetSlice() []string

func (*TimestampSliceValue) Replace

func (t *TimestampSliceValue) Replace(val []string) error

func (*TimestampSliceValue) Set

func (t *TimestampSliceValue) Set(val string) error

func (*TimestampSliceValue) String

func (t *TimestampSliceValue) String() string

String defines a "native" format for this timestamp slice flag value.

func (*TimestampSliceValue) Type

func (t *TimestampSliceValue) Type() string

Type returns a string that uniquely represents this flag's type.

type TimestampValue

type TimestampValue struct {
	// contains filtered or unexported fields
}

func Timestamp

func Timestamp(wrap *timestamppb.Timestamp, formats []string) *TimestampValue

func (*TimestampValue) Set

func (t *TimestampValue) Set(s string) error

func (*TimestampValue) String

func (t *TimestampValue) String() string

func (*TimestampValue) Type

func (t *TimestampValue) Type() string

type UInt32Value

type UInt32Value wrapperspb.UInt32Value

func UInt32

func (*UInt32Value) Set

func (u *UInt32Value) Set(s string) error

func (*UInt32Value) String

func (u *UInt32Value) String() string

func (*UInt32Value) Type

func (u *UInt32Value) Type() string

type UInt64Value

type UInt64Value wrapperspb.UInt64Value

func UInt64

func (*UInt64Value) Set

func (u *UInt64Value) Set(s string) error

func (*UInt64Value) String

func (u *UInt64Value) String() string

func (*UInt64Value) Type

func (u *UInt64Value) Type() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL