convert

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Description = "As default, it will read task defination from stdin, if --file was given, it would read from the file."
View Source
var Flags = []cli.Flag{
	cli.StringFlag{
		Name:  "file,f",
		Usage: "read task defination from `FILE`",
	},
	cli.StringFlag{
		Name:  "source,s",
		Usage: "the `TYPE` convert fromt",
	},
	cli.StringFlag{
		Name:  "target,t",
		Usage: "the `TYPE` convert to",
	},
	cli.StringFlag{
		Name:  "name",
		Usage: "the convert `FUNCTION` name ",
	},
	cli.StringSliceFlag{
		Name:  "assign,a",
		Usage: "the exists covnert functions",
	},
	cli.StringFlag{
		Name:  "error",
		Usage: "the error returns",
	},
	cli.StringFlag{
		Name:  "output,o",
		Usage: "the `FILE` to output",
	},
	cli.StringSliceFlag{
		Name:  "import,i",
		Usage: "the requried imports",
	},
	cli.StringFlag{
		Name:  "tag,g",
		Usage: "the tag name",
		Value: "pc",
	},
}
View Source
var Usage = "convert one type to another"

Functions

func Action

func Action(c *cli.Context) error

Types

type CustomAssign

type CustomAssign struct {
	Source parser.Type
	Target parser.Type
	Assign parser.Type
	Check  string
}

type Field

type Field struct {
	Name string
	//@CHECK:
	Type *Type
	// contains filtered or unexported fields
}

type Generator

type Generator struct {
	generator.Generator

	TagName           string
	Imports           []ImportLine
	CustomAssigns     []*CustomAssign
	Resolves          []string
	IgnoreImportPaths []string
	// contains filtered or unexported fields
}

func NewGenerator

func NewGenerator() *Generator

func (*Generator) AddImport

func (g *Generator) AddImport(name string, path string) string

func (*Generator) Generate

func (g *Generator) Generate(yamlConf *YamlConfig) error

func (*Generator) PrepareAssigns

func (g *Generator) PrepareAssigns(assignConf map[string]YamlCustomAssign)

func (*Generator) PrepareImports

func (g *Generator) PrepareImports(imports map[string]string)

func (*Generator) PrepareTaskes

func (g *Generator) PrepareTaskes(taskConf map[string]YamlTaskElem)

func (*Generator) Run

func (g *Generator) Run()

generate produces the function

type ImportLine

type ImportLine struct {
	Name string
	Path string
}

func (ImportLine) String

func (l ImportLine) String() string

type StructInfo

type StructInfo struct {
	*Type
	Origin string
	// contains filtered or unexported fields
}

func NewStructInfo

func NewStructInfo(origin string) *StructInfo

func (*StructInfo) Print

func (si *StructInfo) Print()

type TaskGenerator

type TaskGenerator struct {
	Parent      *Generator
	Tpaths      []*parser.TPath
	FuncBuilder builder.Builder
	Task        *genTask
	Error       ast.Expr
}

func (*TaskGenerator) Run

func (tg *TaskGenerator) Run() bool

type Type

type Type struct {
	parser.Type
	PackageName string
	Name        string
	Stars       int
}

func NewType

func NewType(t parser.Type) *Type

func (*Type) ElemName

func (t *Type) ElemName() string

func (*Type) FullName

func (t *Type) FullName() string

type YamlConfig

type YamlConfig struct {
	Version   string
	TagName   string
	Dir       string
	Files     []string
	Imports   map[string]string
	Output    string
	Assigns   map[string]YamlCustomAssign
	Generates map[string]YamlTaskElem
}

type YamlCustomAssign

type YamlCustomAssign struct {
	Source string
	Target string
	Assign string
	Check  string
}

type YamlTaskElem

type YamlTaskElem struct {
	Name         string
	Source       string
	Target       string
	Depend       string
	SourceError  string `yaml:"source_error"`
	WithoutError bool   `yaml:"without_error"`
}

Jump to

Keyboard shortcuts

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