Documentation
¶
Overview ¶
Package generator provides shared utilities for project code generation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseGenerator ¶
type BaseGenerator struct {
// TemplateFiles is the embedded filesystem containing template files
TemplateFiles fs.FS
// TemplateRoot is the root directory within TemplateFiles (usually "templates")
TemplateRoot string
}
BaseGenerator provides common functionality for all project generators. It handles template walking, rendering, and file creation with consistent error handling and logging across both agent and MCP generators.
func NewBaseGenerator ¶
func NewBaseGenerator(templateFiles fs.FS, templateRoot string) *BaseGenerator
NewBaseGenerator creates a new base generator with the specified configuration.
func (*BaseGenerator) GenerateProject ¶
func (g *BaseGenerator) GenerateProject(config ProjectConfig) error
GenerateProject generates a new project using the provided templates. It walks through all template files, renders them with the config data, and writes the results to the target directory.
func (*BaseGenerator) ReadTemplateFile ¶
func (g *BaseGenerator) ReadTemplateFile(templatePath string) ([]byte, error)
ReadTemplateFile reads a template file from the embedded filesystem. This is a convenience method for reading individual template files.
func (*BaseGenerator) RenderTemplate ¶
func (g *BaseGenerator) RenderTemplate(tmplContent string, data interface{}) (string, error)
RenderTemplate renders a template string with the provided data. This is the core template rendering logic used by all generators.
type ProjectConfig ¶
type ProjectConfig interface {
// GetDirectory returns the target directory for project generation
GetDirectory() string
// IsVerbose returns whether verbose logging is enabled
IsVerbose() bool
// ShouldInitGit returns whether to initialize a git repository
ShouldInitGit() bool
// ShouldSkipPath returns whether to skip a specific template path
ShouldSkipPath(path string) bool
}
ProjectConfig defines the interface that project configuration must implement. This allows both agent and MCP configs to use the same base generator.