mirror of
https://github.com/go-micro/go-micro.git
synced 2025-05-13 21:16:43 +02:00
Document Gomu's generator package (#2262)
This commit is contained in:
parent
5b8d22a463
commit
ac21bb5b19
@ -7,6 +7,9 @@ import (
|
|||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Generator is the interface that generates project template files.
|
||||||
|
//
|
||||||
|
// Generate accepts a list of files and generates them based on their template.
|
||||||
type Generator interface {
|
type Generator interface {
|
||||||
Generate([]File) error
|
Generate([]File) error
|
||||||
}
|
}
|
||||||
@ -15,8 +18,11 @@ type generator struct {
|
|||||||
opts Options
|
opts Options
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// File represents a file to generate.
|
||||||
type File struct {
|
type File struct {
|
||||||
|
// Path specifies where the file will reside.
|
||||||
Path string
|
Path string
|
||||||
|
// Template is the template used to generate the file.
|
||||||
Template string
|
Template string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,47 +1,62 @@
|
|||||||
package generator
|
package generator
|
||||||
|
|
||||||
|
// Options represents the options for the generator.
|
||||||
type Options struct {
|
type Options struct {
|
||||||
|
// Service is the name of the service the generator will generate files
|
||||||
|
// for.
|
||||||
Service string
|
Service string
|
||||||
|
// Vendor is the service vendor.
|
||||||
Vendor string
|
Vendor string
|
||||||
|
// Directory is the directory where the files will be generated to.
|
||||||
Directory string
|
Directory string
|
||||||
|
|
||||||
|
// Client determines whether or not the project is a client project.
|
||||||
Client bool
|
Client bool
|
||||||
|
// Jaeger determines whether or not Jaeger integration is enabled.
|
||||||
Jaeger bool
|
Jaeger bool
|
||||||
|
// Jaeger determines whether or not Skaffold integration is enabled.
|
||||||
Skaffold bool
|
Skaffold bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Option manipulates the Options passed.
|
||||||
type Option func(o *Options)
|
type Option func(o *Options)
|
||||||
|
|
||||||
|
// Service sets the service name.
|
||||||
func Service(s string) Option {
|
func Service(s string) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.Service = s
|
o.Service = s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Vendor sets the service vendor.
|
||||||
func Vendor(v string) Option {
|
func Vendor(v string) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.Vendor = v
|
o.Vendor = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Directory sets the directory in which files are generated.
|
||||||
func Directory(d string) Option {
|
func Directory(d string) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.Directory = d
|
o.Directory = d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Client sets whether or not the project is a client project.
|
||||||
func Client(c bool) Option {
|
func Client(c bool) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.Client = c
|
o.Client = c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Jaeger sets whether or not Jaeger integration is enabled.
|
||||||
func Jaeger(j bool) Option {
|
func Jaeger(j bool) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.Jaeger = j
|
o.Jaeger = j
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skaffold sets whether or not Skaffold integration is enabled.
|
||||||
func Skaffold(s bool) Option {
|
func Skaffold(s bool) Option {
|
||||||
return func(o *Options) {
|
return func(o *Options) {
|
||||||
o.Skaffold = s
|
o.Skaffold = s
|
||||||
|
Loading…
x
Reference in New Issue
Block a user