option

package
v1.2.113 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TagOption          = "option"
	TagOptionFlagShort = "short" // `option:",short"`
)

Variables

This section is empty.

Functions

func FilterTypeName

func FilterTypeName(exp ast.Expr) (fieldType string, fieldIsMap bool, fieldSliceElt string)

func FormatTypeDeclaration

func FormatTypeDeclaration(tparams *ast.FieldList) (string, error)

FormatTypeDeclaration turns TypeParamList into its Go representation, such as: [T, Y comparable]. Note that it does not print constraints as this is mainly used for formatting type params in method receivers.

func FormatTypeParams

func FormatTypeParams(tparams *ast.FieldList) string

FormatTypeParams turns TypeParamList into its Go representation, such as: [T, Y]. Note that it does not print constraints as this is mainly used for formatting type params in method receivers.

func IsExported added in v1.2.84

func IsExported(arg reflect.Value) bool

func Main

func Main()

func Usage

func Usage()

Usage is a replacement usage function for the flags package.

Types

type File

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

File holds a single parsed file and associated data.

type Generator

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

Generator holds the state of the analysis. Primarily used to buffer the output for format.Source.

func (*Generator) Printf

func (g *Generator) Printf(format string, args ...interface{})

Printf format & write to the buf in this generator

func (*Generator) Render

func (g *Generator) Render(text string, arg interface{})

func (*Generator) Reset

func (g *Generator) Reset()

Reset resets the buffer to be empty, but it retains the underlying storage for use by future writes.

type Package

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

Package holds a single parsed package and associated files and ast files.

type Struct

type Struct struct {
	FileImports                  []string // The import path of the file contains the struct
	StructTypeImport             string   // The import path of StructTypeName.
	StructTypeName               string   // The StructTypeName of the struct.
	StructTypeGenericDeclaration string   // the Generic type of the struct type
	StructTypeGenericTypeParams  string   // the Generic params of the struct type

	IsStruct bool
	Fields   []StructField
	// contains filtered or unexported fields
}

Struct represents a declared constant.

type StructField

type StructField struct {
	FieldName        string                // The FieldName of the struct field.
	FieldType        string                // The FieldType of the struct field.
	FieldDocComment  *ast.CommentGroup     // The doc comment of the struct field.
	FieldLineComment *ast.CommentGroup     // The line comment of the struct field.
	OptionTag        reflect_.SubStructTag // The OptionTag of the struct field.
	FieldIsMap       bool                  // The FieldType of the struct field is a map.
	FieldSliceElt    string                // slice elt type name, for ...type_of_slice_element

	FormatFieldName     string   // The format FieldName of the struct field.
	FormatFieldComments []string // The format comment of the struct field.
}

type TmplConfigRender

type TmplConfigRender struct {
	// Print the header and package clause.
	GoOptionToolName       string
	GoOptionToolArgs       []string
	GoOptionToolArgsJoined string

	PackageName string
	ImportPaths []string
	ValDecls    []string

	TargetTypeName               string // type name of target type
	TargetTypeImport             string // import path of target type
	TargetTypeGenericDeclaration string // the Generic type of the struct type
	TargetTypeGenericParams      string // the Generic params of the struct type
	TrimmedTypeName              string // trimmed type name of target type

	OptionInterfaceName string // option interface name of target type
	OptionStructName    string // option struct name of target type

	ApplyOptionsAsMemberFunction bool // ApplyOptions can be registered as OptionType's member function
}

func (*TmplConfigRender) Complete

func (t *TmplConfigRender) Complete()

type TmplOptionRender

type TmplOptionRender struct {
	// Print the header and package clause.
	GoOptionToolName       string
	GoOptionToolArgs       []string
	GoOptionToolArgsJoined string

	PackageName string
	ImportPaths []string
	ValDecls    []string

	TargetTypeName               string // type name of target type
	TargetTypeImport             string // import path of target type
	TargetTypeGenericDeclaration string // the Generic type of the struct type
	TargetTypeGenericParams      string // the Generic params of the struct type
	TrimmedTypeName              string // trimmed type name of target type

	FormatTypeName string        // The format FieldName of the struct type.
	Fields         []StructField // fields if target type is struct

	OptionInterfaceName string // option interface name of target type
	OptionStructName    string // option struct name of target type

	ApplyOptionsAsMemberFunction bool // ApplyOptions can be registered as OptionType's member function
	WithTargetTypeNameAsPrefix   bool // WithXXX() can be generated as {{OptionType}}WithXXX()
}

func (*TmplOptionRender) Complete

func (t *TmplOptionRender) Complete()

type Value

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

Value represents a declared constant.

func (*Value) String

func (v *Value) String() string

Jump to

Keyboard shortcuts

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