generator

package
v2.1.2131-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const Client = "client"
View Source
const ClientDescription = "client HTTP library"
View Source
const ClientTitle = "Client library"
View Source
const GeneratePath = "generate-path"
View Source
const GeneratePathDescription = "path to generate source code into"
View Source
const GeneratePathTitle = "Generate path"
View Source
const Jsonlib = "jsonlib"
View Source
const JsonlibDescription = "json serialization/deserialization library"
View Source
const JsonlibTitle = "JSON library"
View Source
const ModuleName = "module-name"
View Source
const ModuleNameDescription = "module name"
View Source
const ModuleNameTitle = "Module name"
View Source
const OutFile = "out-file"
View Source
const OutFileDescription = "path to output file"
View Source
const OutFileTitle = "Output file path"
View Source
const PackageName = "package-name"
View Source
const PackageNameDescription = "package name"
View Source
const PackageNameTitle = "Package name"
View Source
const Server = "server"
View Source
const ServerDescription = "server HTTP library/framework"
View Source
const ServerTitle = "Server library"
View Source
const ServicesPath = "services-path"
View Source
const ServicesPathDescription = "path to scaffold services code"
View Source
const ServicesPathTitle = "Services path"
View Source
const SpecFile = "spec-file"
View Source
const SpecFileDescription = "path to specification file"
View Source
const SpecFileTitle = "Spec file path"
View Source
const SwaggerPath = "swagger-path"
View Source
const SwaggerPathDescription = "path of generated OpenAPI (Swagger) specification file"
View Source
const SwaggerPathTitle = "Swagger path"
View Source
const Validation = "validation"
View Source
const ValidationDescription = "type validation library"
View Source
const ValidationTitle = "Type validation library"

Variables

Functions

func AddCobraCommands

func AddCobraCommands(parent *cobra.Command, generators []Generator)

func ExecuteTemplate

func ExecuteTemplate(content string, data interface{}) (string, error)

func WriteFile

func WriteFile(file *CodeFile, overwrite bool) (bool, error)

func WriteFiles

func WriteFiles(files []CodeFile, overwrite bool, processedFile ProcessedFileCallback) error

Types

type Arg

type Arg struct {
	Name        string
	Title       string
	Description string
}

type CodeFile

type CodeFile struct {
	Path    string
	Content string
}

type Config

type Config struct {
	IndentationStr            string
	LeadSpacesIndentationSize int
	Substitutions             map[string]string
}

type Generator

type Generator struct {
	Name      string
	Title     string
	Usage     string
	Args      []GeneratorArg
	Generator GeneratorFunc
}

type GeneratorArg

type GeneratorArg struct {
	Arg
	Values   []string
	Required bool
	Default  string
}

type GeneratorArgsValues

type GeneratorArgsValues map[Arg]string

type GeneratorFunc

type GeneratorFunc func(specification *spec.Spec, params GeneratorArgsValues) *Sources

type ProcessedFileCallback

type ProcessedFileCallback func(wrote bool, fullpath string)

type Sources

type Sources struct {
	Generated  []CodeFile
	Scaffolded []CodeFile
}

func NewSources

func NewSources() *Sources

func (*Sources) AddGenerated

func (sources *Sources) AddGenerated(files ...*CodeFile)

func (*Sources) AddGeneratedAll

func (sources *Sources) AddGeneratedAll(files []CodeFile)

func (*Sources) AddScaffolded

func (sources *Sources) AddScaffolded(files ...*CodeFile)

func (*Sources) AddScaffoldedAll

func (sources *Sources) AddScaffoldedAll(files []CodeFile)

func (*Sources) Write

func (sources *Sources) Write(overwriteAll bool, processedFile ProcessedFileCallback) error

type Writer

type Writer interface {
	Line(format string, args ...interface{})
	Lines(format string)
	Template(data map[string]string, content string)
	EmptyLine()
	Indent()
	Unindent()
	IndentWith(size int)
	UnindentWith(size int)
	Indented() Writer
	IndentedWith(size int) Writer
	ToCodeFile() *CodeFile
	String() string
}

func NewWriter

func NewWriter(config Config) Writer

func NewWriter2 added in v2.1.2134

func NewWriter2(filename string, config Config) Writer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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