Documentation
¶
Overview ¶
Package genutil holds small shared helpers for the generation commands (theme resolution from props, flag-default fallbacks, output paths).
Index ¶
- func FirstNonEmpty(vals ...string) string
- func FirstNonZero(vals ...float64) float64
- func OrDefault(s, def string) string
- func Reader(ctx context.Context, p *props.Props) config.Reader
- func RefImageFromBytes(data []byte) provider.RefImage
- func ResolveTheme(ctx context.Context, p *props.Props, keyword string) (theme.Theme, error)
- func ThemeForGen(ctx context.Context, p *props.Props, keyword string) (theme.Theme, error)
- func WriteFile(fs afero.Fs, path string, data []byte) error
- func WriteImages(fs afero.Fs, prefix string, imgs []provider.Image) ([]string, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FirstNonEmpty ¶
FirstNonEmpty returns the first non-empty string.
func FirstNonZero ¶
FirstNonZero returns the first non-zero float.
func Reader ¶ added in v0.9.0
Reader returns the config every generator should read through: keryx's composed store, or whatever store props carries when there is nothing to compose from (the studio's project-scoped props, or a test's injected store).
Exported so avatars, providers and storage resolve through the SAME layers as themes. They each take a config.Reader and inherit whatever their caller has — so a caller reaching for props.Config directly is how one area silently ends up reading different files from another (spec 0048).
func RefImageFromBytes ¶
RefImageFromBytes builds an image-to-image reference from raw bytes, detecting its MIME type from content. The one place reference photos become provider input (portraits, avatars, card actor-direction).
func ResolveTheme ¶
ResolveTheme loads the catalog from the active config and resolves a theme by keyword (empty → the configured default).
It resolves through the LAYERED theme store (~/.keryx/themes.yaml, the legacy ~/.keryx/config.yaml, and the project's .keryx.yaml) rather than p.Config, whose file list does not include themes.yaml — reading through that would make a promoted theme invisible to every generator (spec 0042 §3.6).
There is no target argument, and no type. A theme is an aesthetic and resolves the same way whatever is being generated; the TARGET enters later, at theme.Theme.PromptFor, where it supplies the format (spec 0047 D4).
func ThemeForGen ¶
ThemeForGen resolves a theme for a generator, hard-failing on an explicitly named but unregistered keyword (CLI-TEST-REPORT B-10 — an unknown --theme must not silently fall back to the zero theme), while tolerating "no keyword + no configured default" as an unthemed render (the zero theme). Load errors propagate.
The zero theme is not an empty prompt: under 0047 it still yields the target's format, the author's subject and the hardening, which is a sensible bare render. keryx seeds no themes (0046), so a fresh install has to be able to generate.
func WriteFile ¶
WriteFile writes generated artefact bytes to path, creating the parent directory first — a fresh workspace doesn't pre-create the per-kind takes/ dirs, and on a real OS filesystem afero.WriteFile won't make them, so without this the provider call (paid) succeeds and the bytes are then dropped (CLI-TEST-REPORT B-1).
Types ¶
This section is empty.