generator

package
v2.1.1963-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 10, 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 struct {
	// contains filtered or unexported fields
}

func NewWriter

func NewWriter(config Config) *Writer

func (*Writer) EmptyLine

func (writer *Writer) EmptyLine()

func (*Writer) Indent

func (writer *Writer) Indent()

func (*Writer) IndentWith

func (writer *Writer) IndentWith(size int)

func (*Writer) Indented

func (writer *Writer) Indented() *Writer

func (*Writer) IndentedWith

func (writer *Writer) IndentedWith(size int) *Writer

func (*Writer) Line

func (writer *Writer) Line(format string, args ...interface{})

func (*Writer) Lines

func (writer *Writer) Lines(format string, args ...interface{})

func (*Writer) String

func (writer *Writer) String() string

func (*Writer) Unindent

func (writer *Writer) Unindent()

func (*Writer) UnindentWith

func (writer *Writer) UnindentWith(size int)

func (Writer) Write

func (writer Writer) Write(s string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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