generator

package
v2.1.2199-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 12 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 TheWriter

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

func (*TheWriter) EmptyLine

func (w *TheWriter) EmptyLine()

func (*TheWriter) Indent

func (w *TheWriter) Indent()

func (*TheWriter) IndentWith

func (w *TheWriter) IndentWith(size int)

func (*TheWriter) Indented

func (w *TheWriter) Indented() Writer

func (*TheWriter) IndentedWith

func (w *TheWriter) IndentedWith(size int) Writer

func (*TheWriter) Line

func (w *TheWriter) Line(format string, args ...interface{})

func (*TheWriter) LineAligned

func (w *TheWriter) LineAligned(format string, args ...interface{})

func (*TheWriter) Lines

func (w *TheWriter) Lines(content string)

func (*TheWriter) String

func (w *TheWriter) String() string

func (*TheWriter) Template

func (w *TheWriter) Template(data map[string]string, content string)

func (*TheWriter) ToCodeFile

func (w *TheWriter) ToCodeFile() *CodeFile

func (*TheWriter) Unindent

func (w *TheWriter) Unindent()

func (*TheWriter) UnindentWith

func (w *TheWriter) UnindentWith(size int)

type Writer

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

func NewWriter

func NewWriter(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