generator

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 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 Jsonmode = "jsonmode"
View Source
const JsonmodeDescription = "json serialization/deserialization mode"
View Source
const JsonmodeTitle = "JSON mode"
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()
	LineAligned(format string, args ...interface{})
	Indent()
	Unindent()
	IndentWith(size int)
	UnindentWith(size int)
	Indented() Writer
	IndentedWith(size int) Writer
	String() string
	Code() []string
}

func NewWriter

func NewWriter(config Config) Writer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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