Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Set = wire.NewSet( grapicmd.CtxSet, ProvideGrapiCtx, ProvideCtx, ProvideTemplateFS, ProvideShouldRun, NewGenerator, App{}, )
Set contains providers for DI.
Functions ¶
func ProvideGrapiCtx ¶
func ProvideTemplateFS ¶
func ProvideTemplateFS(cmd *Command) http.FileSystem
Types ¶
type Command ¶
type Command struct {
// Use, Short, Long, Example and Args are pass-through into *cobra.Command object.
Use string
Short string
Long string
Example string
Args cobra.PositionalArgs
// BuildParams returns parameters to generate/destroy files(required).
BuildParams func(c *Command, args []string) (interface{}, error)
// PreRun is executed in *cobra.Command.PreRunE.
PreRun func(c *Command, args []string) error
// PostRun is executed in *cobra.Command.PostRunE.
PostRun func(c *Command, args []string) error
// ShouldRun is executed for each generated files. When it returns false, the file will be skipped.
ShouldRun ShouldRunFunc
// ShouldInsideApp will disable the command when a current working directory is not inside of a grapi project.
ShouldInsideApp bool
// TemplateFS contains file templates(required).
TemplateFS http.FileSystem
// contains filtered or unexported fields
}
Command represents a subcommand of a generator plugin. It will be converted to a *cobra.Command object internally.
type CreateAppFunc ¶
CreateAppFunc initializes dependencies.
type Ctx ¶
type Ctx struct {
*grapicmd.Ctx
CreateAppFunc CreateAppFunc
}
Ctx defines a context of a generator.
func ProvideCtx ¶
type Generator ¶
func NewGenerator ¶
func NewGenerator( fs afero.Fs, ui cli.UI, rootDir cli.RootDir, templateFS http.FileSystem, shouldRunFunc ShouldRunFunc, ) Generator
type Option ¶
type Option func(*Ctx)
Option configures a command context.
func WithCreateAppFunc ¶
func WithCreateAppFunc(f CreateAppFunc) Option
WithCreateAppFunc specifies a dependencies initializer.
func WithGrapiCtx ¶
WithGrapiCtx specifies a grapi command context.
type ShouldRunFunc ¶
func ProvideShouldRun ¶
func ProvideShouldRun(cmd *Command) ShouldRunFunc
type TemplateString ¶
type TemplateString string
TemplateString is a compilable string with text/template package
func (TemplateString) Compile ¶
func (s TemplateString) Compile(v interface{}) (string, error)
Compile generates textual output applied a parsed template to the specified values
Source Files
¶
Click to show internal directories.
Click to hide internal directories.