gencli

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2019 License: Apache-2.0 Imports: 11 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"
	// OutputOnlyStr represents the comment-level string that
	// indicates a field is only present as output, never input
	OutputOnlyStr = "Output only"
	// RequiredStr represents the comment-level string that
	// indicates a field is required
	RequiredStr = "Required"
)
View Source
const (
	// ShortDescMax is the maximum length accepted for
	// the Short usage docs
	ShortDescMax = 50
)

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
	Method            string
	MethodCmd         string
	InputMessageType  string
	InputMessage      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
	IsLRO             bool
	HasEnums          bool
	SubCommands       []*Command
}

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

type Flag

type Flag struct {
	Name          string
	Type          descriptor.FieldDescriptorProto_Type
	Message       string
	Repeated      bool
	Required      bool
	Usage         string
	MessageImport pbinfo.ImportSpec
	OneOfs        map[string]*Flag
	IsOneOfField  bool
	IsNested      bool
}

Flag is used to represent fields as flags

func (*Flag) GenFlag

func (f *Flag) GenFlag(in string) string

GenFlag generates the pflag API call for this flag

func (*Flag) GenOneOfVarName

func (f *Flag) GenOneOfVarName(in string) string

GenOneOfVarName generates the variable name for a oneof entry type

func (*Flag) GenOtherVarName

func (f *Flag) GenOtherVarName(in string) string

GenOtherVarName generates the Go variable to store repeated Message & Enum string values

func (*Flag) GenRequired

func (f *Flag) GenRequired() string

GenRequired generates the code to mark the flag as required

func (*Flag) InputFieldName

func (f *Flag) InputFieldName() string

InputFieldName converts the field name into the Go struct property name

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) OneOfInputFieldName

func (f *Flag) OneOfInputFieldName() string

OneOfInputFieldName converts the field name into the Go struct property name for a oneof field, which excludes the oneof definition name

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