internal

package
v0.0.0-...-5794a62 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const CutrYAML = "cutr.yaml"

Variables

This section is empty.

Functions

func CollectValues

func CollectValues(variables map[string]Variable, order []string) (map[string]any, error)

CollectValues prompts for and collects user input for template variables

func Generate

func Generate(opts Options) error

Generate performs the complete template generation workflow

func ShowProgress

func ShowProgress(message, successMessage string, operation func() error) error

ShowProgress displays a progress bar for long-running operations

Types

type Config

type Config struct {
	// Template metadata
	Name        string `yaml:"name"`
	Description string `yaml:"description,omitempty"`
	Version     string `yaml:"version,omitempty"`
	Author      string `yaml:"author,omitempty"`
	Repository  string `yaml:"repository,omitempty"`

	// Template variables
	Variables map[string]Variable `yaml:"variables"`

	// Optional hooks
	Hooks Hooks `yaml:"hooks,omitempty"`

	// Template settings
	Template TemplateSettings `yaml:"template,omitempty"`
	// contains filtered or unexported fields
}

Config represents the complete cutr template configuration

func ParseCutrYAML

func ParseCutrYAML(data []byte) (Config, error)

ParseCutrYAML parses a cutr.yaml configuration file

func (Config) GetVariableOrder

func (c Config) GetVariableOrder() []string

GetVariableOrder returns variable names in their YAML definition order

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor handles hook execution operations.

func New

func New() *Executor

New creates a new hook executor.

func NewWithStream

func NewWithStream(stream *tap.Stream) *Executor

NewWithStream creates a new hook executor with a provided tap stream.

func (*Executor) ExecutePostGeneration

func (e *Executor) ExecutePostGeneration(ctx context.Context, hooks Hooks, workDir string, data map[string]any) error

ExecutePostGeneration executes post-generation hooks.

func (*Executor) ExecutePreGeneration

func (e *Executor) ExecutePreGeneration(ctx context.Context, hooks Hooks, workDir string, data map[string]any) error

ExecutePreGeneration executes pre-generation hooks.

type Hooks

type Hooks struct {
	PreGeneration  []string `yaml:"pre_generation,omitempty"`
	PostGeneration []string `yaml:"post_generation,omitempty"`
}

Hooks defines pre and post generation commands

type Options

type Options struct {
	Source    string // Template source (path or URL)
	OutputDir string // Output directory
}

Options contains the configuration for template generation

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

Renderer handles template rendering operations.

func NewRenderer

func NewRenderer() *Renderer

New creates a new template renderer.

func (*Renderer) RenderTree

func (r *Renderer) RenderTree(srcRoot, outRoot string, data map[string]any) error

RenderTree walks the source template directory and renders all files to the output directory.

func (*Renderer) RenderTreeWithSettings

func (r *Renderer) RenderTreeWithSettings(srcRoot, outRoot string, data map[string]any, settings TemplateSettings) error

RenderTreeWithSettings walks the source template directory and renders all files to the output directory using the provided template settings.

type Resolver

type Resolver struct{}

Resolver handles template source resolution (local paths or git repositories)

func NewResolver

func NewResolver() *Resolver

NewResolver creates a new source resolver

func (*Resolver) Resolve

func (r *Resolver) Resolve(src string) (string, func(), error)

Resolve resolves a template source and returns the local path and optional cleanup function

type TemplateSettings

type TemplateSettings struct {
	IgnorePatterns  []string `yaml:"ignore_patterns,omitempty"`
	KeepPermissions bool     `yaml:"keep_permissions,omitempty"`
}

TemplateSettings defines template engine configuration

type Variable

type Variable struct {
	Type    string   `yaml:"type"`
	Prompt  string   `yaml:"prompt,omitempty"`
	Default any      `yaml:"default,omitempty"`
	Choices []string `yaml:"choices,omitempty"`
	Pattern string   `yaml:"pattern,omitempty"`
	Help    string   `yaml:"help,omitempty"`
	Min     int      `yaml:"min,omitempty"`
	Max     int      `yaml:"max,omitempty"`
}

Variable represents a template variable definition

func (Variable) Validate

func (v Variable) Validate(value any) error

Validate validates a value against the variable constraints

Jump to

Keyboard shortcuts

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