dsl

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyFilter

func ApplyFilter(filter string, value string) (string, error)

func Evaluate

func Evaluate(node Node, ctx Context) (bool, error)

func Interpolate

func Interpolate(template string, ctx Context) (string, error)

func InterpolateFile

func InterpolateFile(content []byte, ctx Context) ([]byte, error)

Types

type BinaryNode

type BinaryNode struct {
	Left     Node
	Operator string // "&&" | "||"
	Right    Node
}

BinaryNode represents a logical binary expression: left && right | left || right.

type BoolLiteralNode

type BoolLiteralNode struct {
	Value bool
}

BoolLiteralNode represents a boolean literal.

type CallNode added in v0.2.0

type CallNode struct {
	FuncName string
	Args     []Node
}

CallNode represents function calls like contains(features, "docker").

type CompareNode

type CompareNode struct {
	Left     Node
	Operator string // "==" | "!="
	Right    Node
}

CompareNode represents a comparison expression: left == right | left != right.

type Computed added in v0.2.0

type Computed struct {
	ID    string `yaml:"id"`
	Value string `yaml:"value"`
}

type Context

type Context map[string]interface{}

Context contains the runtime values for all variables referenced in expressions and used during interpolation.

type FileRule

type FileRule struct {
	Include string `yaml:"include,omitempty"`
	Exclude string `yaml:"exclude,omitempty"`
	When    string `yaml:"when,omitempty"`
}

FileRule controls which files or directories are included or excluded.

type IdentNode

type IdentNode struct {
	Name string
}

IdentNode represents an identifier (variable reference).

type Input

type Input struct {
	ID        string   `yaml:"id"`
	Prompt    string   `yaml:"prompt"`
	Type      string   `yaml:"type"`
	Required  bool     `yaml:"required"`
	Default   any      `yaml:"default,omitempty"`
	Validate  string   `yaml:"validate,omitempty"`
	Options   []string `yaml:"options,omitempty"`
	When      string   `yaml:"when,omitempty"`
	MustExist bool     `yaml:"must_exist,omitempty"`
}

Input describes a single user-provided value in scaffold.yaml.

type Lexer

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

func NewLexer

func NewLexer(input string) *Lexer

func (*Lexer) NextToken

func (l *Lexer) NextToken() Token

type Manifest

type Manifest struct {
	Name         string     `yaml:"name"`
	Version      string     `yaml:"version"`
	Author       string     `yaml:"author"`
	Language     string     `yaml:"language"`
	Architecture string     `yaml:"architecture"`
	Description  string     `yaml:"description"`
	Tags         []string   `yaml:"tags"`
	Inputs       []Input    `yaml:"inputs"`
	Computed     []Computed `yaml:"computed,omitempty"`
	Files        []FileRule `yaml:"files"`
	Steps        []Step     `yaml:"steps"`
}

Manifest models the full scaffold.yaml manifest.

func LoadManifest

func LoadManifest(path string) (*Manifest, error)

func ParseManifest added in v0.5.0

func ParseManifest(data []byte) (*Manifest, error)

ParseManifest parses scaffold YAML from bytes (no file I/O).

type Node

type Node interface {
	// contains filtered or unexported methods
}

Node is the base interface for all AST nodes.

type NotNode

type NotNode struct {
	Expr Node
}

NotNode represents a logical NOT expression: !expr.

type Parser

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

func NewParser

func NewParser(input string) *Parser

func (*Parser) Parse

func (p *Parser) Parse() (Node, error)

type Step

type Step struct {
	Name string `yaml:"name"`
	Run  string `yaml:"run"`
	When string `yaml:"when,omitempty"`
}

Step represents a post-generation command to execute.

type StringLiteralNode

type StringLiteralNode struct {
	Value string
}

StringLiteralNode represents a string literal.

type Token

type Token struct {
	Type    TokenType
	Literal string
	Pos     int // position in the original input string
}

Token represents a single lexical token with its literal value and position.

type TokenType

type TokenType string

TokenType represents the type of a token produced by the lexer.

const (
	// Literals
	TOKEN_STRING TokenType = "STRING" // "http"
	TOKEN_BOOL   TokenType = "BOOL"   // true | false
	TOKEN_IDENT  TokenType = "IDENT"  // transport, orm, project_name

	// Operators
	TOKEN_EQ     TokenType = "==" // ==
	TOKEN_NEQ    TokenType = "!=" // !=
	TOKEN_AND    TokenType = "&&" // &&
	TOKEN_OR     TokenType = "||" // ||
	TOKEN_NOT    TokenType = "!"  // !
	TOKEN_LPAREN TokenType = "("
	TOKEN_RPAREN TokenType = ")"
	TOKEN_COMMA  TokenType = ","

	// Control
	TOKEN_EOF     TokenType = "EOF"
	TOKEN_ILLEGAL TokenType = "ILLEGAL"
)

Token types for the DSL lexer.

type ValidationError

type ValidationError struct {
	Field   string
	Message string
}

func ValidateManifest

func ValidateManifest(m *Manifest) []ValidationError

Jump to

Keyboard shortcuts

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