gencli

package
v0.41.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// EmptyProtoType is the type name for the Empty message type
	EmptyProtoType = "google.protobuf.Empty"
	// LROProtoType is the type name for the LRO message type
	LROProtoType = "google.longrunning.Operation"
)
View Source
const (
	// ShortDescMax is the maximum length accepted for
	// the Short usage docs
	ShortDescMax = 50

	// LongDescMax is the maximum length accepted for
	// the Long usage docs
	LongDescMax = 150
)

Variables

This section is empty.

Functions

func Gen

Gen is the main entry point for code generation of a command line utility

Types

type Command

type Command struct {
	Service           string
	ServiceClientType string
	Method            string
	MethodCmd         string
	InputMessageType  string
	InputMessage      string
	InputMessageVar   string
	ShortDesc         string
	LongDesc          string
	Imports           map[string]*pbinfo.ImportSpec
	Flags             []*Flag
	OneOfSelectors    map[string]*Flag
	NestedMessages    []*NestedMessage
	EnvPrefix         string
	OutputMessageType string
	ServerStreaming   bool
	ClientStreaming   bool
	Paged             bool
	HasPageSize       bool
	HasPageToken      bool
	IsLRO             bool
	IsLRORespEmpty    bool
	HasEnums          bool
	HasOptional       bool
	SubCommands       []*Command
}

Command intermediate representation of a RPC/Method as a CLI command

type Flag

type Flag struct {
	Name          string
	Type          descriptorpb.FieldDescriptorProto_Type
	Message       string
	Repeated      bool
	Required      bool
	Usage         string
	MessageImport pbinfo.ImportSpec
	OneOfs        map[string]*Flag
	OneOfSelector string
	OneOfDesc     *desc.OneOfDescriptor
	VarName       string
	FieldName     string
	SliceAccessor string
	IsOneOfField  bool
	IsNested      bool
	IsMap         bool
	Optional      bool

	// Accessor is only set after calling GenFlag
	Accessor string
	MsgDesc  *desc.MessageDescriptor
}

Flag is used to represent fields as flags

func (*Flag) EnumFieldAccess added in v0.13.0

func (f *Flag) EnumFieldAccess(inputVar string) string

EnumFieldAccess constructs the input message field accessor for an enum assignment.

func (*Flag) GenFlag

func (f *Flag) GenFlag() string

GenFlag generates the pflag API call for this flag

func (*Flag) GoTypeForPrim added in v0.14.0

func (f *Flag) GoTypeForPrim() string

GoTypeForPrim returns the name of the Go type for a primitive proto type.

func (*Flag) IsBytes added in v0.4.0

func (f *Flag) IsBytes() bool

IsBytes is a helper that reports if the flag is of a type bytes

func (*Flag) IsEnum

func (f *Flag) IsEnum() bool

IsEnum is a template helper that reports if the flag is of an enum type

func (*Flag) IsMessage

func (f *Flag) IsMessage() bool

IsMessage is a template helper that reports if the flag is a message type

func (*Flag) OptionalVarName added in v0.14.0

func (f *Flag) OptionalVarName() string

OptionalVarName constructs the place holder variable name for a proto3 optional field.

type NestedMessage

type NestedMessage struct {
	FieldName string
	FieldType string
}

NestedMessage represents a nested message that will need to be initialized in the generated code

Jump to

Keyboard shortcuts

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