generate

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package generate loads explicit pfw declarations and emits Go initializers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, cfg Config) ([]string, error)

Run validates the selected graphs and type-checks generated code before writing any files. Check reports missing or stale files without modifying them.

Types

type BindingReport

type BindingReport struct {
	Consumer       string   `json:"consumer"`
	Interface      string   `json:"interface"`
	SelectedType   string   `json:"selected_type"`
	Provider       string   `json:"provider"`
	Mode           string   `json:"mode"`
	AutoBindScopes []string `json:"autobind_scopes"`
}

type Config

type Config struct {
	Dir      string
	Patterns []string
	Output   string
	Check    bool
	// Environment selects the graph to generate, or filters inspection.
	// Generation requires it for initializers with an Environment parameter.
	Environment string
}

Config describes a generation run. Output is a filename within each target package; place templates in the package where initializers should be emitted.

type Entry

type Entry struct {
	Package, Root string
	Initializers  []string
}

func FindEntry

func FindEntry(ctx context.Context, dir, pattern string) (Entry, error)

FindEntry locates initializer packages reachable from a single main package, within its module. It does not assume a bootstrap folder or template filename.

type InitializerReport

type InitializerReport struct {
	Package           string           `json:"package"`
	Name              string           `json:"name"`
	Environment       string           `json:"environment,omitempty"`
	Root              string           `json:"root"`
	WithCleanup       bool             `json:"with_cleanup"`
	Inputs            []InputReport    `json:"inputs"`
	Providers         []ProviderReport `json:"providers"`
	Modules           []ModuleReport   `json:"modules"`
	Bindings          []BindingReport  `json:"bindings"`
	ConstructionOrder []string         `json:"construction_order"`
	CleanupOrder      []string         `json:"cleanup_order"`
}

type InputReport

type InputReport struct {
	Name string `json:"name"`
	Type string `json:"type"`
}

type ModuleReport

type ModuleReport struct {
	Name      string   `json:"name"`
	Source    string   `json:"source"`
	AutoBind  bool     `json:"autobind"`
	Providers []string `json:"providers"`
}

type ProviderReport

type ProviderReport struct {
	Name               string   `json:"name"`
	Output             string   `json:"output"`
	Dependencies       []string `json:"dependencies"`
	Origins            []string `json:"origins"`
	Modules            []string `json:"modules"`
	AutoBindScopes     []string `json:"autobind_scopes"`
	Source             string   `json:"source"`
	Status             string   `json:"status"`
	ExclusionRequested bool     `json:"exclusion_requested"`
	Fallible           bool     `json:"fallible"`
	Cleanup            bool     `json:"cleanup"`
	Override           bool     `json:"override,omitempty"`
}

type Report

type Report struct {
	Version      int                 `json:"version"`
	Initializers []InitializerReport `json:"initializers"`
}

func Inspect

func Inspect(ctx context.Context, cfg Config) (Report, error)

Inspect validates and describes the same graph used by generation. It never emits/writes Go files or evaluates constructors/configuration at runtime.

func (Report) WriteText

func (report Report) WriteText(w io.Writer, settings ...TextOptions) error

WriteText renders a compact execution view; JSON retains full report metadata.

type TextOptions

type TextOptions struct {
	FullNames bool
	Color     bool
}

Jump to

Keyboard shortcuts

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