worldscaffold

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: LGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstantiateTemplate

func InstantiateTemplate(ctx context.Context, url, version, targetDir, subdir string) error

InstantiateTemplate clones a git template and turns it into a ready-to-build project named after targetDir's base: it writes a go.mod, rewrites example imports to the module path, and sets world.toml's project field. On any failure the partially-created targetDir is removed so the name stays retryable. All paths are explicit — no os.Chdir.

func Scaffold

func Scaffold(ctx context.Context, tmpl GameTemplate, targetDir string) error

Scaffold creates a new project at targetDir from the given template: it clones and instantiates the template (see InstantiateTemplate) at the World Engine release this binary was built from, then tidies dependencies. It is the single entry point for callers that don't manage the individual steps (e.g. the editor). On any failure it leaves nothing behind — targetDir is removed so the name stays retryable.

func Tidy

func Tidy(ctx context.Context, projectDir string) error

Tidy runs go mod tidy in the specified project directory. Uses os/exec with explicit cmd.Dir — does not depend on or modify CWD.

Types

type GameTemplate

type GameTemplate struct {
	Name        string
	ShortName   string // Short name for CLI flag usage (e.g., "basic", "demo", "bare")
	Description string
	URL         string
	Subdir      string
}

GameTemplate represents a game template that can be cloned.

func GetAvailableTemplates

func GetAvailableTemplates() []GameTemplate

GetAvailableTemplates returns all available game templates.

func GetTemplateByName

func GetTemplateByName(name string) (*GameTemplate, error)

GetTemplateByName finds a template by its short name (case-insensitive). Returns an error if the template is not found.

Jump to

Keyboard shortcuts

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